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
-
- All Implemented Interfaces:
CustomComparableType
public class ValueType extends PrimitiveOrValueType
Value class in a client's domain model is a simple value holder.
JaVers doesn't interact with internal properties of Values and treats them similarly to primitives.
Two Values are compared usingObject.equals(Object)so it's highly important to implement it properly by comparing underlying fields.
If you don't control theequals()implementation in a Value class you can still provide aCustomValueComparatorand register it withJaversBuilder.registerValue(Class, CustomValueComparator).
It's highly advisable to implement Values as immutable objects, likeBigDecimalorLocalDateTime.
Values are serialized to JSON using Gson defaults, if it's not what you need, implementJsonTypeAdapterfor 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 booleancanBePrototype()java.lang.ClassgetBaseJavaClass()protected java.lang.reflect.TypegetRawDehydratedType()Type for JSON representation.booleanisInstance(java.lang.Object cdo)java.lang.StringvalueToString(java.lang.Object value)-
Methods inherited from class org.javers.core.metamodel.type.PrimitiveOrValueType
equals, hasCustomValueComparator, isBoolean, isJsonPrimitive, isNumber, isStringy, prettyPrintBuilder
-
Methods inherited from class org.javers.core.metamodel.type.JaversType
equals, getBaseJavaType, getConcreteClassTypeArguments, getName, hashCode, isGenericType, prettyPrint, toString
-
-
-
-
Method Detail
-
valueToString
public java.lang.String valueToString(java.lang.Object value)
-
canBePrototype
public boolean canBePrototype()
- Specified by:
canBePrototypein classJaversType
-
isInstance
public boolean isInstance(java.lang.Object cdo)
- Specified by:
isInstancein 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()
-
-