Class 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, implement JsonTypeAdapter for custom serialization and register it with JaversBuilder.registerValueTypeAdapter(JsonTypeAdapter)
    • Constructor Detail

      • ValueType

        public ValueType​(java.lang.reflect.Type baseJavaType)
    • Method Detail

      • isInstance

        public boolean isInstance​(java.lang.Object cdo)
        Specified by:
        isInstance in class JaversType
      • 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()