Package org.javers.core.metamodel.type
Class ValueType
- java.lang.Object
-
- org.javers.core.metamodel.type.JaversType
-
- org.javers.core.metamodel.type.PrimitiveOrValueType
-
- org.javers.core.metamodel.type.ValueType
-
public class ValueType extends PrimitiveOrValueType
Value class in client's domain model. Simple value holder.
JaVers doesn't interact with internal properties of this type but treats its similarly to primitives.
Two Value instances are compared using equals() so it's highly important to implement it properly by comparing underlying field (or fields).
It's highly advisable to implement Values as immutable objects, for example:BigDecimal
,LocalDateTime
Values are serialized to JSON using Gson defaults, if it's not what you need, implementJsonTypeAdapter
for custom serialization and register it withJaversBuilder.registerValueTypeAdapter(JsonTypeAdapter)
-
-
Field Summary
-
Fields inherited from class org.javers.core.metamodel.type.JaversType
DEFAULT_TYPE_PARAMETER
-
-
Constructor Summary
Constructors Constructor Description ValueType(java.lang.reflect.Type baseJavaType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canBePrototype()
java.lang.Class
getBaseJavaClass()
protected java.lang.reflect.Type
getRawDehydratedType()
Type for JSON representation.boolean
isInstance(java.lang.Object cdo)
java.lang.String
smartToString(java.lang.Object cdo)
-
Methods inherited from class org.javers.core.metamodel.type.PrimitiveOrValueType
equals, isBoolean, isJsonPrimitive, isNumber, isStringy
-
Methods inherited from class org.javers.core.metamodel.type.JaversType
equals, getBaseJavaType, getConcreteClassTypeArguments, getName, hashCode, isGenericType, prettyPrint, prettyPrintBuilder, toString
-
-
-
-
Method Detail
-
smartToString
public java.lang.String smartToString(java.lang.Object cdo)
- Specified by:
smartToString
in classPrimitiveOrValueType
-
canBePrototype
public boolean canBePrototype()
- Specified by:
canBePrototype
in classJaversType
-
isInstance
public boolean isInstance(java.lang.Object cdo)
- Specified by:
isInstance
in classJaversType
-
getRawDehydratedType
protected java.lang.reflect.Type getRawDehydratedType()
Type for JSON representation. For Values it's simply baseJavaType. For ManagedTypes (references to Entities and ValueObjects) it's GlobalId because JaVers serializes references in the 'dehydrated' form.
-
getBaseJavaClass
public java.lang.Class getBaseJavaClass()
-
-