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 Summary
Fields Modifier and Type Field Description static BasicUserType<?>
INSTANCE
-
Constructor Summary
Constructors Constructor Description ImmutableBasicUserType()
-
Method Summary
Modifier and Type Method Description X
deepClone(X object)
Clones the given object if the type is mutable to be able to detect mutations.X
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.int
hashCode(X object)
Returns the hash code of the object for lookups in hash based collections.boolean
isDeepEqual(X initial, X current)
Returnstrue
if the given objects are equal regarding their values.boolean
isEqual(X initial, X current)
Returnstrue
if the given objects are equal regarding their identity.boolean
isMutable()
Returnstrue
if the type is mutable,false
otherwise.boolean
shouldPersist(X entity)
Returnstrue
if the given entity object should be persisted.boolean
supportsDeepCloning()
Returnstrue
if the type supports creating deep clones,false
otherwise.boolean
supportsDeepEqualChecking()
Returnstrue
if the type supports checking deep equality,false
otherwise.boolean
supportsDirtyChecking()
Returnstrue
if the type supports dirty checking,false
otherwise.boolean
supportsDirtyTracking()
Returnstrue
if the type supports dirty tracking,false
otherwise.String
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
-
Constructor Details
-
ImmutableBasicUserType
public ImmutableBasicUserType()
-
-
Method Details
-
isMutable
public boolean isMutable()Description copied from interface:BasicUserType
Returnstrue
if the type is mutable,false
otherwise.- Specified by:
isMutable
in interfaceBasicUserType<X>
- Returns:
- true if mutable, false otherwise
-
supportsDirtyChecking
public boolean supportsDirtyChecking()Description copied from interface:BasicUserType
Returnstrue
if the type supports dirty checking,false
otherwise. This is only relevant when the type is also mutable.- Specified by:
supportsDirtyChecking
in interfaceBasicUserType<X>
- Returns:
- true if dirty checking is supported, false otherwise
-
supportsDirtyTracking
public boolean supportsDirtyTracking()Description copied from interface:BasicUserType
Returnstrue
if the type supports dirty tracking,false
otherwise. Support for dirty tracking implies that the type implements theBasicDirtyTracker
interface. 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:
supportsDirtyTracking
in interfaceBasicUserType<X>
- Returns:
- true if dirty tracking is supported, false otherwise
-
supportsDeepEqualChecking
public boolean supportsDeepEqualChecking()Description copied from interface:BasicUserType
Returnstrue
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 interfaceBasicUserType<X>
- Returns:
- true if deep equality checking is supported, false otherwise
-
supportsDeepCloning
public boolean supportsDeepCloning()Description copied from interface:BasicUserType
Returnstrue
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 returntrue
.- Specified by:
supportsDeepCloning
in interfaceBasicUserType<X>
- Returns:
- true if deep cloning is supported, false otherwise
-
isEqual
Description copied from interface:BasicUserType
Returnstrue
if the given objects are equal regarding their identity. For value types, this is the same as deep equality checking.- Specified by:
isEqual
in interfaceBasicUserType<X>
- Parameters:
initial
- The first objectcurrent
- The second object- Returns:
- true if the objects are equal, false otherwise
-
isDeepEqual
Description copied from interface:BasicUserType
Returnstrue
if the given objects are equal regarding their values. If deep equality is not supported, returns false.- Specified by:
isDeepEqual
in interfaceBasicUserType<X>
- Parameters:
initial
- The first objectcurrent
- The second object- Returns:
- true if the objects are equal, false otherwise
-
hashCode
Description copied from interface:BasicUserType
Returns the hash code of the object for lookups in hash based collections.- Specified by:
hashCode
in interfaceBasicUserType<X>
- Parameters:
object
- The object- Returns:
- the hash code of the object
-
shouldPersist
Description copied from interface:BasicUserType
Returnstrue
if the given entity object should be persisted. This is invoked for user types where the typeT
is an entity type. If the type is not an entity type, returns false.- Specified by:
shouldPersist
in 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: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 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: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 returnsfalse
or dirty checking is properly supported.- Specified by:
deepClone
in interfaceBasicUserType<X>
- Parameters:
object
- The object to clone- Returns:
- The cloned object
-
fromString
Description copied from interface:BasicUserTypeStringSupport
Creates an instance of the type from the given string representation.- Specified by:
fromString
in interfaceBasicUserTypeStringSupport<X>
- Parameters:
sequence
- A string representation of the object- Returns:
- The object
-
toStringExpression
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 byBasicUserTypeStringSupport.fromString(CharSequence)
.- Specified by:
toStringExpression
in interfaceBasicUserTypeStringSupport<X>
- Parameters:
expression
- The JPQL.Next expression string- Returns:
- The object
-