S - The concrete type of the smart object.public abstract class SmartObject<S extends SmartObject<S>> extends Object implements Comparable<S>, craterdog.core.Composite
Object class. It also adds a generics based copy() method that is
superior to the clone() method in many ways.| Constructor and Description |
|---|
SmartObject() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addSerializableClass(Class<?> serializable)
This protected method allows a subclass to add to the mappers a class type that can be
serialized using its toString().
|
protected void |
addSerializableClass(Class<?> serializable,
Class<?> mixin)
This protected method allows a subclass to add to the mappers a class type that can be
serialized using mixin class.
|
protected void |
addSerializableClass(com.fasterxml.jackson.databind.Module module)
This protected method allows a subclass to add to the mappers a Jackson module that can
be used to serialize and deserialize instances of the subclass.
|
int |
compareTo(S object) |
<T extends SmartObject<S>> |
copy()
This method should work for all objects.
|
static com.fasterxml.jackson.databind.ObjectMapper |
createMapper(com.fasterxml.jackson.databind.Module... modules)
This function generates a new object mapper with the specified modules.
|
boolean |
equals(Object object)
This method determines whether or not two objects are equal.
|
static <T> T |
fromString(Class<T> classType,
String json)
This function takes string containing Javascript Object Notation (JSON) and
uses it to construct the corresponding smart object.
|
static <T> T |
fromString(com.fasterxml.jackson.core.type.TypeReference<T> classType,
String json)
This function takes string containing Javascript Object Notation (JSON) and
uses it to construct the corresponding smart object.
|
int |
hashCode()
This method returns a hash code for the object based on its string form.
|
protected String |
toExposedString()
This method behaves similarly to the
toString() method except that it
does not perform any censorship of sensitive attributes. |
String |
toString()
This method returns a string containing a structured, human readable version of the object.
|
static String |
toString(Object object)
This function generates a Javascript Object Notation (JSON) string from
an object.
|
static String |
toString(Object object,
String indentation)
This function generates an indented Javascript Object Notation (JSON) string from
an object.
|
String |
toString(String indentation) |
public String toString()
public String toString(String indentation)
toString in interface craterdog.core.Compositeprotected String toExposedString()
toString() method except that it
does not perform any censorship of sensitive attributes. It should only be used when
the resulting output will not be stored or seen by anyone.public boolean equals(Object object)
public int compareTo(S object)
compareTo in interface Comparable<S extends SmartObject<S>>public <T extends SmartObject<S>> T copy()
T - The concrete type of the smart object.public int hashCode()
public static <T> T fromString(Class<T> classType, String json) throws IOException
Customer customer = SmartObject.fromString(Customer.class, jsonString);
T - The type of object being constructed.classType - The concrete class type being constructed.json - The JSON string.IOException - The JSON string could not be parsed correctly.public static <T> T fromString(com.fasterxml.jackson.core.type.TypeReference<T> classType,
String json)
throws IOException
List<String> list = SmartObject.fromString(new TypeReference<List<String>>() { }, jsonString);
The anonymous type declaration is required due to Java's erasure of parameterized
types at runtime.T - The type of object being constructed.classType - The parameterized class type being constructed.json - The JSON string.IOException - The JSON string could not be parsed correctly.public static String toString(Object object)
object - The object to be turned into a JSON string.public static String toString(Object object, String indentation)
object - The object to be turned into a JSON string.indentation - The amount of space that should be prepended to each line.public static com.fasterxml.jackson.databind.ObjectMapper createMapper(com.fasterxml.jackson.databind.Module... modules)
ObjectMapper mapper = SmartObject.createMapper(new CensorshipModule());
modules - The list of modules that should be added to the object mapper.protected void addSerializableClass(Class<?> serializable)
serializable - The type of class that can be serialized using its toString() method.protected void addSerializableClass(Class<?> serializable, Class<?> mixin)
serializable - The type of class that can be serialized using its toString() method.mixin - The type of class that can be used to serialized the serializable class.protected void addSerializableClass(com.fasterxml.jackson.databind.Module module)
module - The type of class that can be serialized using its toString() method.Copyright © 2015 Crater Dog Technologies(TM). All rights reserved.