public class LoganSquare
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static com.fasterxml.jackson.core.JsonFactory |
JSON_FACTORY
The JsonFactory that should be used throughout the entire app.
|
| Constructor and Description |
|---|
LoganSquare() |
| Modifier and Type | Method and Description |
|---|---|
static <E> JsonMapper<E> |
mapperFor(java.lang.Class<E> cls)
Returns a JsonMapper for a given class that has been annotated with @JsonObject.
|
static <E> JsonMapper<E> |
mapperFor(ParameterizedType<E> type)
Returns a JsonMapper for a given class that has been annotated with @JsonObject.
|
static <E> JsonMapper<E> |
mapperFor(ParameterizedType<E> type,
SimpleArrayMap<ParameterizedType,JsonMapper> partialMappers) |
static <E> E |
parse(java.io.InputStream is,
java.lang.Class<E> jsonObjectClass)
Parse an object from an InputStream.
|
static <E> E |
parse(java.io.InputStream is,
ParameterizedType<E> jsonObjectType)
Parse a parameterized object from an InputStream.
|
static <E> E |
parse(java.lang.String jsonString,
java.lang.Class<E> jsonObjectClass)
Parse an object from a String.
|
static <E> E |
parse(java.lang.String jsonString,
ParameterizedType<E> jsonObjectType)
Parse a parameterized object from a String.
|
static <E> java.util.List<E> |
parseList(java.io.InputStream is,
java.lang.Class<E> jsonObjectClass)
Parse a list of objects from an InputStream.
|
static <E> java.util.List<E> |
parseList(java.lang.String jsonString,
java.lang.Class<E> jsonObjectClass)
Parse a list of objects from a String.
|
static <E> java.util.Map<java.lang.String,E> |
parseMap(java.io.InputStream is,
java.lang.Class<E> jsonObjectClass)
Parse a map of objects from an InputStream.
|
static <E> java.util.Map<java.lang.String,E> |
parseMap(java.lang.String jsonString,
java.lang.Class<E> jsonObjectClass)
Parse a map of objects from a String.
|
static <E> void |
registerTypeConverter(java.lang.Class<E> cls,
TypeConverter<E> converter)
Register a new TypeConverter for parsing and serialization.
|
static <E> java.lang.String |
serialize(E object)
Serialize an object to a JSON String.
|
static <E> void |
serialize(E object,
java.io.OutputStream os)
Serialize an object to an OutputStream.
|
static <E> java.lang.String |
serialize(E object,
ParameterizedType<E> parameterizedType)
Serialize a parameterized object to a JSON String.
|
static <E> void |
serialize(E object,
ParameterizedType<E> parameterizedType,
java.io.OutputStream os)
Serialize a parameterized object to an OutputStream.
|
static <E> java.lang.String |
serialize(java.util.List<E> list,
java.lang.Class<E> jsonObjectClass)
Serialize a list of objects to a JSON String.
|
static <E> void |
serialize(java.util.List<E> list,
java.io.OutputStream os,
java.lang.Class<E> jsonObjectClass)
Serialize a list of objects to an OutputStream.
|
static <E> java.lang.String |
serialize(java.util.Map<java.lang.String,E> map,
java.lang.Class<E> jsonObjectClass)
Serialize a map of objects to a JSON String.
|
static <E> void |
serialize(java.util.Map<java.lang.String,E> map,
java.io.OutputStream os,
java.lang.Class<E> jsonObjectClass)
Serialize a map of objects to an OutputStream.
|
static boolean |
supports(java.lang.Class cls)
Returns whether or not LoganSquare can handle a given class.
|
static boolean |
supports(ParameterizedType type)
Returns whether or not LoganSquare can handle a given ParameterizedType.
|
static <E> TypeConverter<E> |
typeConverterFor(java.lang.Class<E> cls)
Returns a TypeConverter for a given class.
|
public static final com.fasterxml.jackson.core.JsonFactory JSON_FACTORY
public static <E> E parse(java.io.InputStream is,
java.lang.Class<E> jsonObjectClass)
throws java.io.IOException
is - The InputStream, most likely from your networking library.jsonObjectClass - The @JsonObject class to parse the InputStream intojava.io.IOExceptionpublic static <E> E parse(java.lang.String jsonString,
java.lang.Class<E> jsonObjectClass)
throws java.io.IOException
jsonString - The JSON string being parsed.jsonObjectClass - The @JsonObject class to parse the InputStream intojava.io.IOExceptionpublic static <E> E parse(java.io.InputStream is,
ParameterizedType<E> jsonObjectType)
throws java.io.IOException
is - The InputStream, most likely from your networking library.jsonObjectType - The ParameterizedType describing the object. Ex: LoganSquare.parse(is, new ParameterizedType<MyModel<OtherModel>>() { });java.io.IOExceptionpublic static <E> E parse(java.lang.String jsonString,
ParameterizedType<E> jsonObjectType)
throws java.io.IOException
jsonString - The JSON string being parsed.jsonObjectType - The ParameterizedType describing the object. Ex: LoganSquare.parse(is, new ParameterizedType<MyModel<OtherModel>>() { });java.io.IOExceptionpublic static <E> java.util.List<E> parseList(java.io.InputStream is,
java.lang.Class<E> jsonObjectClass)
throws java.io.IOException
is - The inputStream, most likely from your networking library.jsonObjectClass - The @JsonObject class to parse the InputStream intojava.io.IOExceptionpublic static <E> java.util.List<E> parseList(java.lang.String jsonString,
java.lang.Class<E> jsonObjectClass)
throws java.io.IOException
jsonString - The JSON string being parsed.jsonObjectClass - The @JsonObject class to parse the InputStream intojava.io.IOExceptionpublic static <E> java.util.Map<java.lang.String,E> parseMap(java.io.InputStream is,
java.lang.Class<E> jsonObjectClass)
throws java.io.IOException
is - The inputStream, most likely from your networking library.jsonObjectClass - The @JsonObject class to parse the InputStream intojava.io.IOExceptionpublic static <E> java.util.Map<java.lang.String,E> parseMap(java.lang.String jsonString,
java.lang.Class<E> jsonObjectClass)
throws java.io.IOException
jsonString - The JSON string being parsed.jsonObjectClass - The @JsonObject class to parse the InputStream intojava.io.IOExceptionpublic static <E> java.lang.String serialize(E object)
throws java.io.IOException
object - The object to serialize.java.io.IOExceptionpublic static <E> void serialize(E object,
java.io.OutputStream os)
throws java.io.IOException
object - The object to serialize.os - The OutputStream being written to.java.io.IOExceptionpublic static <E> java.lang.String serialize(E object,
ParameterizedType<E> parameterizedType)
throws java.io.IOException
object - The object to serialize.parameterizedType - The ParameterizedType describing the object. Ex: LoganSquare.serialize(object, new ParameterizedType<MyModel<OtherModel>>() { });java.io.IOExceptionpublic static <E> void serialize(E object,
ParameterizedType<E> parameterizedType,
java.io.OutputStream os)
throws java.io.IOException
object - The object to serialize.parameterizedType - The ParameterizedType describing the object. Ex: LoganSquare.serialize(object, new ParameterizedType<MyModel<OtherModel>>() { }, os);os - The OutputStream being written to.java.io.IOExceptionpublic static <E> java.lang.String serialize(java.util.List<E> list,
java.lang.Class<E> jsonObjectClass)
throws java.io.IOException
list - The list of objects to serialize.jsonObjectClass - The @JsonObject class of the list elementsjava.io.IOExceptionpublic static <E> void serialize(java.util.List<E> list,
java.io.OutputStream os,
java.lang.Class<E> jsonObjectClass)
throws java.io.IOException
list - The list of objects to serialize.os - The OutputStream to which the list should be serializedjsonObjectClass - The @JsonObject class of the list elementsjava.io.IOExceptionpublic static <E> java.lang.String serialize(java.util.Map<java.lang.String,E> map,
java.lang.Class<E> jsonObjectClass)
throws java.io.IOException
map - The map of objects to serialize.jsonObjectClass - The @JsonObject class of the list elementsjava.io.IOExceptionpublic static <E> void serialize(java.util.Map<java.lang.String,E> map,
java.io.OutputStream os,
java.lang.Class<E> jsonObjectClass)
throws java.io.IOException
map - The map of objects to serialize.os - The OutputStream to which the list should be serializedjsonObjectClass - The @JsonObject class of the list elementsjava.io.IOExceptionpublic static boolean supports(java.lang.Class cls)
cls - The class for which support is being checked.public static boolean supports(ParameterizedType type)
type - The ParameterizedType for which support is being checked.public static <E> JsonMapper<E> mapperFor(java.lang.Class<E> cls) throws NoSuchMapperException
cls - The class for which the JsonMapper should be fetched.NoSuchMapperExceptionpublic static <E> JsonMapper<E> mapperFor(ParameterizedType<E> type) throws NoSuchMapperException
type - The ParameterizedType for which the JsonMapper should be fetched.NoSuchMapperExceptionpublic static <E> JsonMapper<E> mapperFor(ParameterizedType<E> type, SimpleArrayMap<ParameterizedType,JsonMapper> partialMappers) throws NoSuchMapperException
NoSuchMapperExceptionpublic static <E> TypeConverter<E> typeConverterFor(java.lang.Class<E> cls) throws NoSuchTypeConverterException
cls - The class for which the TypeConverter should be fetched.NoSuchTypeConverterExceptionpublic static <E> void registerTypeConverter(java.lang.Class<E> cls,
TypeConverter<E> converter)
cls - The class for which the TypeConverter should be used.converter - The TypeConverter