public interface DTOs
DTOs recognize primary fields (annotated with PrimaryKey). If none of
the fields is annotated, all fields are primary.
| Modifier and Type | Interface and Description |
|---|---|
static interface |
DTOs.Converter
Converts an object to another type
|
static interface |
DTOs.Dec<T>
An interface to control the building of a JSON decoder.
|
static class |
DTOs.Difference
The details of a difference
|
static interface |
DTOs.Enc
This interface is a builder for encoding a DTO to JSON.
|
static class |
DTOs.LiteralMap<K,V>
A map that is to set inline like a builder.
|
static class |
DTOs.Reason
The reason for a difference.
|
static class |
DTOs.Retrieve
The DTO that contains the result of a path traversal.
|
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<java.lang.String,java.lang.Object> |
asMap(java.lang.Object dto)
Return a partially read only Map object that maps directly to a DTO.
|
DTOs.Converter |
convert(java.lang.Object source)
Create a converter on an object.
|
<T> DTOs.Dec<T> |
decoder(java.lang.Class<T> type)
Return a JSON decoder that uses the type to control the parsing.
|
DTOs.Dec<?> |
decoder(java.lang.reflect.Type type,
java.io.InputStream source)
Return a JSON decoder on an input stream that uses the type to control
the parsing.
|
<T> DTOs.Dec<T> |
decoder(TypeReference<T> type)
Return a JSON decoder that uses the type to control the parsing.
|
<T> T |
deepCopy(T object)
Create a deep copy of a DTO.
|
boolean |
deepEquals(java.lang.Object a,
java.lang.Object b)
Check if two DTOs fields are equal.
|
java.util.List<DTOs.Difference> |
diff(java.lang.Object older,
java.lang.Object newer)
Return a list of paths where the two objects differ.
|
DTOs.Enc |
encoder(java.lang.Object source)
Return encoder builder for JSON
|
boolean |
equals(java.lang.Object a,
java.lang.Object b)
Check if two dtos fields are equal.
|
java.lang.String |
escape(java.lang.String unescaped)
Escape a string to be used in a path.
|
java.lang.String[] |
fromPathToSegments(java.lang.String path)
Takes a path with escaped '.'and '\' and then turns it into an array of
unescaped keys
|
java.lang.String |
fromSegmentsToPath(java.lang.String[] segments)
Takes a path with unescaped keys and turns it into a string path where
the \ and .
|
DTOs.Retrieve |
get(java.lang.Object dto,
java.lang.String... path)
Access a DTO with a path that consists of an array with segments.
|
DTOs.Retrieve |
get(java.lang.Object dto,
java.lang.String path)
Access a DTO with a path.
|
<T> java.util.Comparator<T> |
getComparator(java.lang.Class<T> dtoClass)
Return a comparator who works on the primary fields of a DTO class.
|
int |
hashCode(java.lang.Object dto)
Calculate a hash Code for the fields in this DTO.
|
boolean |
isComplex(java.lang.Object object)
Return true if the give dto is complex (either Map, Collection, Array, or
has public fields.
|
boolean |
isDTO(java.lang.Object dto)
An object with public fields.
|
boolean |
isValidDTO(java.lang.Object o)
Verify that the object is a DTO and has no cycles.
|
default <K,V> DTOs.LiteralMap<K,V> |
map(K key,
V value)
Convenience method to create a map that returns itself when set so it can
be used as a builder.
|
DTOs.Retrieve |
set(java.lang.Object dto,
java.lang.Object value,
java.lang.String... path)
Set a value in a DTO with a path that consists of an array with segments.
|
DTOs.Retrieve |
set(java.lang.Object dto,
java.lang.Object value,
java.lang.String path)
Access a DTO with a path.
|
<T> T |
shallowCopy(T object)
Create a shallow copy of a DTO.
|
java.lang.String |
toString(java.lang.Object dto)
Convert a DTO to a human readable string presentation.
|
java.lang.String |
unescape(java.lang.String escaped)
Unescapes a string to be used in a path.
|
DTOs.Converter convert(java.lang.Object source) throws java.lang.Exception
source - The source to convert, null is allowedjava.lang.Exceptionjava.util.Map<java.lang.String,java.lang.Object> asMap(java.lang.Object dto)
throws java.lang.Exception
dto - the DTOjava.lang.ExceptionDTOs.Enc encoder(java.lang.Object source) throws java.lang.Exception
source - the object to encodejava.lang.Exception<T> DTOs.Dec<T> decoder(java.lang.Class<T> type) throws java.lang.Exception
type - the type that controls actual types for parsingjava.lang.Exception<T> DTOs.Dec<T> decoder(TypeReference<T> type) throws java.lang.Exception
type - the type that controls actual types for parsingjava.lang.ExceptionDTOs.Dec<?> decoder(java.lang.reflect.Type type, java.io.InputStream source) throws java.lang.Exception
type - the type that controls actual types for parsingsource - the source of the JSONjava.lang.Exceptionjava.lang.String toString(java.lang.Object dto)
dto - the dto to turn into a stringboolean equals(java.lang.Object a,
java.lang.Object b)
a - the first objectb - the second objectboolean deepEquals(java.lang.Object a,
java.lang.Object b)
a - the first objectb - the second objectint hashCode(java.lang.Object dto)
dto - the object to calculate the hashcode for, must not be null .DTOs.Retrieve get(java.lang.Object dto, java.lang.String path) throws java.lang.Exception
dto - the rootpath - the path, should only contain dots as separatorsjava.lang.ExceptionDTOs.Retrieve get(java.lang.Object dto, java.lang.String... path) throws java.lang.Exception
dto - the rootpath - the pathjava.lang.ExceptionDTOs.Retrieve set(java.lang.Object dto, java.lang.Object value, java.lang.String path) throws java.lang.Exception
get(Object, String...).dto - the rootvalue - the value to setpath - the path, should only contain dots as separatorsjava.lang.ExceptionDTOs.Retrieve set(java.lang.Object dto, java.lang.Object value, java.lang.String... path) throws java.lang.Exception
dto - the rootvalue - the value to setpath - the pathjava.lang.Exception<T> java.util.Comparator<T> getComparator(java.lang.Class<T> dtoClass)
dtoClass - the dto classjava.util.List<DTOs.Difference> diff(java.lang.Object older, java.lang.Object newer) throws java.lang.Exception
older - the older objectnewer - the newer objectjava.lang.Exceptionjava.lang.String[] fromPathToSegments(java.lang.String path)
path - the path with escaped \ and .java.lang.String fromSegmentsToPath(java.lang.String[] segments)
segments - The unescaped segments of the pathjava.lang.String escape(java.lang.String unescaped)
unescaped - the string to be escapedjava.lang.String unescape(java.lang.String escaped)
escaped - the string to be unescapedboolean isComplex(java.lang.Object object)
object - The DTO to checktrue if this is a DTO with fields or length.boolean isDTO(java.lang.Object dto)
dto - the object to checkboolean isValidDTO(java.lang.Object o)
throws java.lang.Exception
o - The object to check for no cyclestrue if this DTO has no cycles and is further okjava.lang.Exception<T> T shallowCopy(T object)
throws java.lang.Exception
object - the source objectjava.lang.Exception<T> T deepCopy(T object)
throws java.lang.Exception
object - the object to deep copyjava.lang.Exceptiondefault <K,V> DTOs.LiteralMap<K,V> map(K key, V value)
key - the initial keyvalue - the initial valueCopyright (c) OSGi Alliance (2014, 2020). All Rights Reserved.