Interface BasicUserType<X>
- Type Parameters:
X
- The type of the user type
- All Superinterfaces:
BasicUserTypeStringSupport<X>
- All Known Subinterfaces:
VersionBasicUserType<X>
- All Known Implementing Classes:
AbstractMutableBasicUserType
,ImmutableBasicUserType
,MutableBasicUserType
A contract for defining a custom basic type to use with entity views.
- Since:
- 1.2.0
- Author:
- Christian Beikov
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String[]
The object to return fromgetDirtyProperties(Object)
when unsure what properties are dirty. -
Method Summary
Modifier and TypeMethodDescriptionClones the given object if the type is mutable to be able to detect mutations.String[]
getDirtyProperties
(X object) Returns the nested properties of the object that are known to be dirty.int
Returns the hash code of the object for lookups in hash based collections.boolean
isDeepEqual
(X object1, X object2) Returnstrue
if the given objects are equal regarding their values.boolean
Returnstrue
if the given objects are equal regarding their identity.boolean
Returnstrue
if the type is mutable,false
otherwise.boolean
shouldPersist
(X entity) Returnstrue
if the given entity object should be persisted.boolean
Returnstrue
if the type supports creating deep clones,false
otherwise.boolean
Returnstrue
if the type supports checking deep equality,false
otherwise.boolean
Returnstrue
if the type supports dirty checking,false
otherwise.boolean
Returnstrue
if the type supports dirty tracking,false
otherwise.Methods inherited from interface com.blazebit.persistence.view.spi.type.BasicUserTypeStringSupport
fromString, toStringExpression
-
Field Details
-
DIRTY_MARKER
The object to return fromgetDirtyProperties(Object)
when unsure what properties are dirty.
-
-
Method Details
-
isMutable
boolean isMutable()Returnstrue
if the type is mutable,false
otherwise.- Returns:
- true if mutable, false otherwise
-
supportsDirtyChecking
boolean supportsDirtyChecking()Returnstrue
if the type supports dirty checking,false
otherwise. This is only relevant when the type is also mutable.- Returns:
- true if dirty checking is supported, false otherwise
-
supportsDirtyTracking
boolean supportsDirtyTracking()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, thesupportsDirtyChecking()
method should also return true.- Returns:
- true if dirty tracking is supported, false otherwise
-
supportsDeepEqualChecking
boolean supportsDeepEqualChecking()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.- Returns:
- true if deep equality checking is supported, false otherwise
-
supportsDeepCloning
boolean supportsDeepCloning()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
.- Returns:
- true if deep cloning is supported, false otherwise
-
isEqual
Returnstrue
if the given objects are equal regarding their identity. For value types, this is the same as deep equality checking.- Parameters:
object1
- The first objectobject2
- The second object- Returns:
- true if the objects are equal, false otherwise
-
isDeepEqual
Returnstrue
if the given objects are equal regarding their values. If deep equality is not supported, returns false.- Parameters:
object1
- The first objectobject2
- The second object- Returns:
- true if the objects are equal, false otherwise
-
hashCode
Returns the hash code of the object for lookups in hash based collections.- Parameters:
object
- The object- Returns:
- the hash code of the object
-
shouldPersist
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.- Parameters:
entity
- The entity for which to determine whether it should be persisted- Returns:
- true if the entity should be persisted, false otherwise
-
getDirtyProperties
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 DIRTY_MARKER is returned.- Parameters:
object
- The object for which to determine the dirty properties- Returns:
- the dirty properties of the object
-
deepClone
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.- Parameters:
object
- The object to clone- Returns:
- The cloned object
-