Class 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 using Object.equals(Object) so it's highly important to implement it properly by comparing underlying fields.

If you don't control the equals() implementation in a Value class you can still provide a CustomValueComparator and register it with JaversBuilder.registerValue(Class, CustomValueComparator).

It's highly advisable to implement Values as immutable objects, like BigDecimal or LocalDateTime.

Values are serialized to JSON using Gson defaults, if it's not what you need, implement JsonTypeAdapter for custom serialization and register it with JaversBuilder.registerValueTypeAdapter(JsonTypeAdapter).
See Also:
  • Constructor Details

  • Method Details

    • valueToString

      public String valueToString(Object value)
    • canBePrototype

      public boolean canBePrototype()
      Specified by:
      canBePrototype in class JaversType
    • isInstance

      public boolean isInstance(Object cdo)
      Specified by:
      isInstance in class JaversType
    • getRawDehydratedType

      protected 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 Class getBaseJavaClass()