Class ImmutableBasicUserType<X>

java.lang.Object
com.blazebit.persistence.view.spi.type.ImmutableBasicUserType<X>
Type Parameters:
X - The type of the user type
All Implemented Interfaces:
BasicUserType<X>, BasicUserTypeStringSupport<X>

public class ImmutableBasicUserType<X>
extends Object
implements BasicUserType<X>
The default basic user type implementation for immutable types.
Since:
1.2.0
Author:
Christian Beikov
  • Field Details

  • Constructor Details

  • Method Details

    • isMutable

      public boolean isMutable()
      Description copied from interface: BasicUserType
      Returns true if the type is mutable, false otherwise.
      Specified by:
      isMutable in interface BasicUserType<X>
      Returns:
      true if mutable, false otherwise
    • supportsDirtyChecking

      public boolean supportsDirtyChecking()
      Description copied from interface: BasicUserType
      Returns true if the type supports dirty checking, false otherwise. This is only relevant when the type is also mutable.
      Specified by:
      supportsDirtyChecking in interface BasicUserType<X>
      Returns:
      true if dirty checking is supported, false otherwise
    • supportsDirtyTracking

      public boolean supportsDirtyTracking()
      Description copied from interface: BasicUserType
      Returns true if the type supports dirty tracking, false otherwise. Support for dirty tracking implies that the type implements the BasicDirtyTracker interface. This is only relevant when the type is also mutable. Note that if this method returns true, the BasicUserType.supportsDirtyChecking() method should also return true.
      Specified by:
      supportsDirtyTracking in interface BasicUserType<X>
      Returns:
      true if dirty tracking is supported, false otherwise
    • supportsDeepEqualChecking

      public boolean supportsDeepEqualChecking()
      Description copied from interface: BasicUserType
      Returns true if the type supports checking deep equality, false otherwise. Deep equality checking, in contrast to normal equality checking, compares objects by their actual values rather than maybe just their identity. For value types, deep equality checking is the same as normal equality checking.
      Specified by:
      supportsDeepEqualChecking in interface BasicUserType<X>
      Returns:
      true if deep equality checking is supported, false otherwise
    • supportsDeepCloning

      public boolean supportsDeepCloning()
      Description copied from interface: BasicUserType
      Returns true if the type supports creating deep clones, false otherwise. Deep clones are only necessary for mutable types that don't support dirty checking. Immutable types can simply return true.
      Specified by:
      supportsDeepCloning in interface BasicUserType<X>
      Returns:
      true if deep cloning is supported, false otherwise
    • isEqual

      public boolean isEqual​(X initial, X current)
      Description copied from interface: BasicUserType
      Returns true if the given objects are equal regarding their identity. For value types, this is the same as deep equality checking.
      Specified by:
      isEqual in interface BasicUserType<X>
      Parameters:
      initial - The first object
      current - The second object
      Returns:
      true if the objects are equal, false otherwise
    • isDeepEqual

      public boolean isDeepEqual​(X initial, X current)
      Description copied from interface: BasicUserType
      Returns true if the given objects are equal regarding their values. If deep equality is not supported, returns false.
      Specified by:
      isDeepEqual in interface BasicUserType<X>
      Parameters:
      initial - The first object
      current - The second object
      Returns:
      true if the objects are equal, false otherwise
    • hashCode

      public int hashCode​(X object)
      Description copied from interface: BasicUserType
      Returns the hash code of the object for lookups in hash based collections.
      Specified by:
      hashCode in interface BasicUserType<X>
      Parameters:
      object - The object
      Returns:
      the hash code of the object
    • shouldPersist

      public boolean shouldPersist​(X entity)
      Description copied from interface: BasicUserType
      Returns true if the given entity object should be persisted. This is invoked for user types where the type T is an entity type. If the type is not an entity type, returns false.
      Specified by:
      shouldPersist in interface BasicUserType<X>
      Parameters:
      entity - The entity for which to determine whether it should be persisted
      Returns:
      true if the entity should be persisted, false otherwise
    • getDirtyProperties

      public String[] getDirtyProperties​(X entity)
      Description copied from interface: BasicUserType
      Returns the nested properties of the object that are known to be dirty. If the object isn't dirty i.e. doesn't need flushing, null is returned. If the properties that are dirty aren't known or the type doesn't have nested properties, an empty array or BasicUserType.DIRTY_MARKER is returned.
      Specified by:
      getDirtyProperties in interface BasicUserType<X>
      Parameters:
      entity - The object for which to determine the dirty properties
      Returns:
      the dirty properties of the object
    • deepClone

      public X deepClone​(X object)
      Description copied from interface: BasicUserType
      Clones the given object if the type is mutable to be able to detect mutations. Immutable types may return the object itself. Types that can't be cloned easily can return the object too, but should make sure, that the deep equality check always returns false or dirty checking is properly supported.
      Specified by:
      deepClone in interface BasicUserType<X>
      Parameters:
      object - The object to clone
      Returns:
      The cloned object
    • fromString

      public X fromString​(CharSequence sequence)
      Description copied from interface: BasicUserTypeStringSupport
      Creates an instance of the type from the given string representation.
      Specified by:
      fromString in interface BasicUserTypeStringSupport<X>
      Parameters:
      sequence - A string representation of the object
      Returns:
      The object
    • toStringExpression

      public String toStringExpression​(String expression)
      Description copied from interface: BasicUserTypeStringSupport
      Wraps the given JPQL.Next expression such that it is converted to the internal string representation that can be read by BasicUserTypeStringSupport.fromString(CharSequence).
      Specified by:
      toStringExpression in interface BasicUserTypeStringSupport<X>
      Parameters:
      expression - The JPQL.Next expression string
      Returns:
      The object