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>
The default basic user type implementation for immutable types.
- Since:
- 1.2.0
- Author:
- Christian Beikov
-
Field Summary
FieldsFields inherited from interface com.blazebit.persistence.view.spi.type.BasicUserType
DIRTY_MARKER -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionClones the given object if the type is mutable to be able to detect mutations.fromString(CharSequence sequence) Creates an instance of the type from the given string representation.String[]getDirtyProperties(X entity) Returns the nested properties of the object that are known to be dirty.intReturns the hash code of the object for lookups in hash based collections.booleanisDeepEqual(X initial, X current) Returnstrueif the given objects are equal regarding their values.booleanReturnstrueif the given objects are equal regarding their identity.booleanReturnstrueif the type is mutable,falseotherwise.booleanshouldPersist(X entity) Returnstrueif the given entity object should be persisted.booleanReturnstrueif the type supports creating deep clones,falseotherwise.booleanReturnstrueif the type supports checking deep equality,falseotherwise.booleanReturnstrueif the type supports dirty checking,falseotherwise.booleanReturnstrueif the type supports dirty tracking,falseotherwise.toStringExpression(String expression) Wraps the given JPQL.Next expression such that it is converted to the internal string representation that can be read byBasicUserTypeStringSupport.fromString(CharSequence).
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
ImmutableBasicUserType
public ImmutableBasicUserType()
-
-
Method Details
-
isMutable
public boolean isMutable()Description copied from interface:BasicUserTypeReturnstrueif the type is mutable,falseotherwise.- Specified by:
isMutablein interfaceBasicUserType<X>- Returns:
- true if mutable, false otherwise
-
supportsDirtyChecking
public boolean supportsDirtyChecking()Description copied from interface:BasicUserTypeReturnstrueif the type supports dirty checking,falseotherwise. This is only relevant when the type is also mutable.- Specified by:
supportsDirtyCheckingin interfaceBasicUserType<X>- Returns:
- true if dirty checking is supported, false otherwise
-
supportsDirtyTracking
public boolean supportsDirtyTracking()Description copied from interface:BasicUserTypeReturnstrueif the type supports dirty tracking,falseotherwise. Support for dirty tracking implies that the type implements theBasicDirtyTrackerinterface. This is only relevant when the type is also mutable. Note that if this method returns true, theBasicUserType.supportsDirtyChecking()method should also return true.- Specified by:
supportsDirtyTrackingin interfaceBasicUserType<X>- Returns:
- true if dirty tracking is supported, false otherwise
-
supportsDeepEqualChecking
public boolean supportsDeepEqualChecking()Description copied from interface:BasicUserTypeReturnstrueif the type supports checking deep equality,falseotherwise. 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:
supportsDeepEqualCheckingin interfaceBasicUserType<X>- Returns:
- true if deep equality checking is supported, false otherwise
-
supportsDeepCloning
public boolean supportsDeepCloning()Description copied from interface:BasicUserTypeReturnstrueif the type supports creating deep clones,falseotherwise. Deep clones are only necessary for mutable types that don't support dirty checking. Immutable types can simply returntrue.- Specified by:
supportsDeepCloningin interfaceBasicUserType<X>- Returns:
- true if deep cloning is supported, false otherwise
-
isEqual
Description copied from interface:BasicUserTypeReturnstrueif the given objects are equal regarding their identity. For value types, this is the same as deep equality checking.- Specified by:
isEqualin interfaceBasicUserType<X>- Parameters:
initial- The first objectcurrent- The second object- Returns:
- true if the objects are equal, false otherwise
-
isDeepEqual
Description copied from interface:BasicUserTypeReturnstrueif the given objects are equal regarding their values. If deep equality is not supported, returns false.- Specified by:
isDeepEqualin interfaceBasicUserType<X>- Parameters:
initial- The first objectcurrent- The second object- Returns:
- true if the objects are equal, false otherwise
-
hashCode
Description copied from interface:BasicUserTypeReturns the hash code of the object for lookups in hash based collections.- Specified by:
hashCodein interfaceBasicUserType<X>- Parameters:
object- The object- Returns:
- the hash code of the object
-
shouldPersist
Description copied from interface:BasicUserTypeReturnstrueif the given entity object should be persisted. This is invoked for user types where the typeTis an entity type. If the type is not an entity type, returns false.- Specified by:
shouldPersistin interfaceBasicUserType<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
Description copied from interface:BasicUserTypeReturns the nested properties of the object that are known to be dirty. If the object isn't dirty i.e. doesn't need flushing,nullis 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:
getDirtyPropertiesin interfaceBasicUserType<X>- Parameters:
entity- The object for which to determine the dirty properties- Returns:
- the dirty properties of the object
-
deepClone
Description copied from interface:BasicUserTypeClones 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 returnsfalseor dirty checking is properly supported.- Specified by:
deepClonein interfaceBasicUserType<X>- Parameters:
object- The object to clone- Returns:
- The cloned object
-
fromString
Description copied from interface:BasicUserTypeStringSupportCreates an instance of the type from the given string representation.- Specified by:
fromStringin interfaceBasicUserTypeStringSupport<X>- Parameters:
sequence- A string representation of the object- Returns:
- The object
-
toStringExpression
Description copied from interface:BasicUserTypeStringSupportWraps the given JPQL.Next expression such that it is converted to the internal string representation that can be read byBasicUserTypeStringSupport.fromString(CharSequence).- Specified by:
toStringExpressionin interfaceBasicUserTypeStringSupport<X>- Parameters:
expression- The JPQL.Next expression string- Returns:
- The object
-