Package is.codion.framework.json.domain
Class EntityObjectMapper
java.lang.Object
com.fasterxml.jackson.core.TreeCodec
com.fasterxml.jackson.core.ObjectCodec
com.fasterxml.jackson.databind.ObjectMapper
is.codion.framework.json.domain.EntityObjectMapper
- All Implemented Interfaces:
com.fasterxml.jackson.core.Versioned,Serializable
public final class EntityObjectMapper
extends com.fasterxml.jackson.databind.ObjectMapper
Entity object mapper for mapping
For instances use the
Entity and Entity.Key to and from JSON.For instances use the
entityObjectMapper(Entities) factory method.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.fasterxml.jackson.databind.ObjectMapper
com.fasterxml.jackson.databind.ObjectMapper.DefaultTypeResolverBuilder, com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.fasterxml.jackson.core.type.TypeReference<List<is.codion.framework.domain.entity.Entity>>static final com.fasterxml.jackson.core.type.TypeReference<List<is.codion.framework.domain.entity.Entity.Key>>Fields inherited from class com.fasterxml.jackson.databind.ObjectMapper
_coercionConfigs, _configOverrides, _deserializationConfig, _deserializationContext, _injectableValues, _jsonFactory, _mixIns, _registeredModuleTypes, _rootDeserializers, _serializationConfig, _serializerFactory, _serializerProvider, _subtypeResolver, _typeFactory, DEFAULT_ANNOTATION_INTROSPECTOR, DEFAULT_BASE -
Method Summary
Modifier and TypeMethodDescription<T> voidaddDeserializer(Class<T> clazz, com.fasterxml.jackson.databind.deser.std.StdDeserializer<? extends T> deserializer) Adds a deserializer to this EntityObjectMapper instance.<T> voidaddSerializer(Class<? extends T> clazz, com.fasterxml.jackson.databind.ser.std.StdSerializer<T> serializer) Adds a serializer to this EntityObjectMapper instance.is.codion.framework.domain.entity.condition.ConditiondeserializeCondition(is.codion.framework.domain.entity.EntityDefinition definition, com.fasterxml.jackson.databind.JsonNode conditionNode) Deserializes the given conditionList<is.codion.framework.domain.entity.Entity>deserializeEntities(InputStream inputStream) Deserializes the given JSON input stream into a list of Entity instancesList<is.codion.framework.domain.entity.Entity>deserializeEntities(String jsonString) Deserializes the given JSON string into a list of Entity instancesList<is.codion.framework.domain.entity.Entity.Key>deserializeKeys(InputStream inputStream) Deserializes the given JSON input stream into a list of Key instancesList<is.codion.framework.domain.entity.Entity.Key>deserializeKeys(String jsonString) Deserializes the given JSON string into a list of Key instancesis.codion.framework.domain.entity.Entitiesentities()static EntityObjectMapperentityObjectMapper(is.codion.framework.domain.entity.Entities entities) A factory method forEntityObjectMapperinstances.com.fasterxml.jackson.databind.Modulemodule()voidserializeCondition(is.codion.framework.domain.entity.condition.Condition condition, com.fasterxml.jackson.core.JsonGenerator generator) Serializes the given conditionserializeEntities(Collection<is.codion.framework.domain.entity.Entity> entities) Serializes the given Entity instances into a JSON string arrayserializeKeys(Collection<is.codion.framework.domain.entity.Entity.Key> keys) Serializes the given Key instances into a JSON string arraysetIncludeForeignKeyValues(boolean includeForeignKeyValues) setIncludeNullValues(boolean includeNullValues) Methods inherited from class com.fasterxml.jackson.databind.ObjectMapper
_assertNotNull, _checkInvalidCopy, _configAndWriteValue, _constructDefaultTypeResolverBuilder, _convert, _findRootDeserializer, _initForReading, _newReader, _newReader, _newWriter, _newWriter, _newWriter, _readMapAndClose, _readTreeAndClose, _readValue, _serializerProvider, _verifyNoTrailingTokens, _verifySchemaType, _writeValueAndClose, acceptJsonFormatVisitor, acceptJsonFormatVisitor, activateDefaultTyping, activateDefaultTyping, activateDefaultTyping, activateDefaultTypingAsProperty, addHandler, addMixIn, addMixInAnnotations, canDeserialize, canDeserialize, canSerialize, canSerialize, clearProblemHandlers, coercionConfigDefaults, coercionConfigFor, coercionConfigFor, configOverride, configure, configure, configure, configure, configure, configure, constructType, constructType, convertValue, convertValue, convertValue, copy, copyWith, createArrayNode, createDeserializationContext, createGenerator, createGenerator, createGenerator, createGenerator, createGenerator, createNonBlockingByteArrayParser, createObjectNode, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, createParser, deactivateDefaultTyping, defaultClassIntrospector, disable, disable, disable, disable, disable, disable, disable, disableDefaultTyping, enable, enable, enable, enable, enable, enable, enable, enableDefaultTyping, enableDefaultTyping, enableDefaultTyping, enableDefaultTypingAsProperty, findAndRegisterModules, findMixInClassFor, findModules, findModules, generateJsonSchema, getDateFormat, getDeserializationConfig, getDeserializationContext, getFactory, getInjectableValues, getNodeFactory, getPolymorphicTypeValidator, getPropertyNamingStrategy, getRegisteredModuleIds, getSerializationConfig, getSerializerFactory, getSerializerProvider, getSerializerProviderInstance, getSubtypeResolver, getTypeFactory, getVisibilityChecker, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, isEnabled, missingNode, mixInCount, nullNode, reader, reader, reader, reader, reader, reader, reader, reader, reader, reader, reader, readerFor, readerFor, readerFor, readerForArrayOf, readerForListOf, readerForMapOf, readerForUpdating, readerWithView, readTree, readTree, readTree, readTree, readTree, readTree, readTree, readTree, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValue, readValues, readValues, readValues, readValues, registerModule, registerModules, registerModules, registerSubtypes, registerSubtypes, registerSubtypes, setAccessorNaming, setAnnotationIntrospector, setAnnotationIntrospectors, setBase64Variant, setCacheProvider, setConfig, setConfig, setConstructorDetector, setDateFormat, setDefaultAttributes, setDefaultLeniency, setDefaultMergeable, setDefaultPrettyPrinter, setDefaultPropertyInclusion, setDefaultPropertyInclusion, setDefaultSetterInfo, setDefaultTyping, setDefaultVisibility, setFilterProvider, setFilters, setHandlerInstantiator, setInjectableValues, setLocale, setMixInAnnotations, setMixInResolver, setMixIns, setNodeFactory, setPolymorphicTypeValidator, setPropertyInclusion, setPropertyNamingStrategy, setSerializationInclusion, setSerializerFactory, setSerializerProvider, setSubtypeResolver, setTimeZone, setTypeFactory, setVisibility, setVisibility, setVisibilityChecker, tokenStreamFactory, treeAsTokens, treeToValue, treeToValue, treeToValue, updateValue, valueToTree, version, writer, writer, writer, writer, writer, writer, writer, writer, writer, writer, writerFor, writerFor, writerFor, writerWithDefaultPrettyPrinter, writerWithType, writerWithType, writerWithType, writerWithView, writeTree, writeTree, writeValue, writeValue, writeValue, writeValue, writeValue, writeValueAsBytes, writeValueAsStringMethods inherited from class com.fasterxml.jackson.core.ObjectCodec
getJsonFactory
-
Field Details
-
KEY_LIST_REFERENCE
public static final com.fasterxml.jackson.core.type.TypeReference<List<is.codion.framework.domain.entity.Entity.Key>> KEY_LIST_REFERENCE -
ENTITY_LIST_REFERENCE
public static final com.fasterxml.jackson.core.type.TypeReference<List<is.codion.framework.domain.entity.Entity>> ENTITY_LIST_REFERENCE
-
-
Method Details
-
entities
public is.codion.framework.domain.entity.Entities entities()- Returns:
- the underlying domain model entities
-
module
public com.fasterxml.jackson.databind.Module module()- Returns:
- the underlying module
-
setIncludeForeignKeyValues
- Parameters:
includeForeignKeyValues- if true then the foreign key graph is included in serialized entities- Returns:
- this
EntityObjectMapperinstance
-
setIncludeNullValues
- Parameters:
includeNullValues- true if null values should be included in exported entities- Returns:
- this
EntityObjectMapperinstance
-
serializeCondition
public void serializeCondition(is.codion.framework.domain.entity.condition.Condition condition, com.fasterxml.jackson.core.JsonGenerator generator) throws IOException Serializes the given condition- Parameters:
condition- the condition to serializegenerator- the json generator- Throws:
IOException- in case of an exception
-
deserializeCondition
public is.codion.framework.domain.entity.condition.Condition deserializeCondition(is.codion.framework.domain.entity.EntityDefinition definition, com.fasterxml.jackson.databind.JsonNode conditionNode) throws IOException Deserializes the given condition- Parameters:
definition- the entity definitionconditionNode- the condition node to deserialize- Returns:
- the deserialized Condition instance
- Throws:
IOException- in case of an exception
-
serializeEntities
public String serializeEntities(Collection<is.codion.framework.domain.entity.Entity> entities) throws com.fasterxml.jackson.core.JsonProcessingException Serializes the given Entity instances into a JSON string array- Parameters:
entities- the entities- Returns:
- a JSON string representation of the given entities
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- in case of an exception
-
deserializeEntities
public List<is.codion.framework.domain.entity.Entity> deserializeEntities(String jsonString) throws com.fasterxml.jackson.core.JsonProcessingException Deserializes the given JSON string into a list of Entity instances- Parameters:
jsonString- the JSON string to parse- Returns:
- a List containing the Entity instances represented by the given JSON string
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- in case of an exception
-
deserializeEntities
public List<is.codion.framework.domain.entity.Entity> deserializeEntities(InputStream inputStream) throws IOException Deserializes the given JSON input stream into a list of Entity instances- Parameters:
inputStream- the JSON input stream to parse- Returns:
- a List containing the Entity instances represented by the given JSON input stream
- Throws:
IOException- in case of an exception
-
serializeKeys
public String serializeKeys(Collection<is.codion.framework.domain.entity.Entity.Key> keys) throws com.fasterxml.jackson.core.JsonProcessingException Serializes the given Key instances into a JSON string array- Parameters:
keys- the keys- Returns:
- a JSON string representation of the given entity keys
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- in case of an exception
-
deserializeKeys
public List<is.codion.framework.domain.entity.Entity.Key> deserializeKeys(String jsonString) throws com.fasterxml.jackson.core.JsonProcessingException Deserializes the given JSON string into a list of Key instances- Parameters:
jsonString- the JSON string to parse- Returns:
- a List containing the Key instances represented by the given JSON string
- Throws:
com.fasterxml.jackson.core.JsonProcessingException- in case of an exception
-
deserializeKeys
public List<is.codion.framework.domain.entity.Entity.Key> deserializeKeys(InputStream inputStream) throws IOException Deserializes the given JSON input stream into a list of Key instances- Parameters:
inputStream- the JSON input stream to parse- Returns:
- a List containing the Key instances represented by the given JSON input stream
- Throws:
IOException- in case of an exception
-
addSerializer
public <T> void addSerializer(Class<? extends T> clazz, com.fasterxml.jackson.databind.ser.std.StdSerializer<T> serializer) Adds a serializer to this EntityObjectMapper instance.- Type Parameters:
T- the type- Parameters:
clazz- the classserializer- the serializer
-
addDeserializer
public <T> void addDeserializer(Class<T> clazz, com.fasterxml.jackson.databind.deser.std.StdDeserializer<? extends T> deserializer) Adds a deserializer to this EntityObjectMapper instance.- Type Parameters:
T- the type- Parameters:
clazz- the classdeserializer- the deserializer
-
entityObjectMapper
public static EntityObjectMapper entityObjectMapper(is.codion.framework.domain.entity.Entities entities) A factory method forEntityObjectMapperinstances.- Parameters:
entities- the domain entities- Returns:
- a new
EntityObjectMapperinstance based on the given entities
-