@MappedSuperclass public abstract class CdmBase extends java.lang.Object implements java.io.Serializable, ICdmBase, ISelfDescriptive, java.lang.Cloneable
VersionableEntity
) of a CDM object, so a locally unique id exists in addition
that allows to safely access and store several objects (=version) with the same UUID.
This class together with the PropertyChangeAspect
will fire bean change events to all registered listeners. Listener registration and event firing
is done with the help of the PropertyChangeSupport
class.Modifier and Type | Field and Description |
---|---|
protected static int |
CLOB_LENGTH |
protected java.util.UUID |
uuid |
Constructor and Description |
---|
CdmBase()
Class constructor assigning a unique UUID and creation date.
|
Modifier and Type | Method and Description |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
see
PropertyChangeSupport.addPropertyChangeListener(PropertyChangeListener) |
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
see
PropertyChangeSupport.addPropertyChangeListener(String, PropertyChangeListener) |
protected <T extends CdmBase> |
addToSetWithChangeEvent(java.util.Set<T> set,
T newItem,
java.lang.String propertyName)
Adds an item to a set of
this object and fires the according
PropertyChangeEvent . |
java.lang.Object |
clone() |
static <T extends CdmBase> |
deproxy(java.lang.Object object,
java.lang.Class<T> clazz)
These methods are present due to HHH-1517 - that in a one-to-many
relationship with a superclass at the "one" end, the proxy created
by hibernate is the superclass, and not the subclass, resulting in
a ClassCastException when you try to cast it.
|
static <T> T |
deproxy(T entity)
If entity is a HibernateProxy it returns the initialized object.
|
boolean |
equals(java.lang.Object obj)
Is
true if UUID and created timestamp (is this really needed/make sense?)
is the same for the passed Object and this one. |
static void |
fireOnCreateEvent(CdmBase cdmBase) |
void |
firePropertyChange(java.beans.PropertyChangeEvent evt) |
void |
firePropertyChange(java.lang.String property,
boolean oldval,
boolean newval) |
void |
firePropertyChange(java.lang.String property,
float oldval,
float newval) |
void |
firePropertyChange(java.lang.String property,
int oldval,
int newval) |
void |
firePropertyChange(java.lang.String property,
java.lang.Object oldval,
java.lang.Object newval) |
void |
firePropertyChange(java.lang.String property,
java.lang.String oldval,
java.lang.String newval) |
org.joda.time.DateTime |
getCreated() |
User |
getCreatedBy() |
int |
getId()
Returns local unique identifier for the concrete subclass
|
java.lang.String |
getUserFriendlyDescription()
A user-friendly description of the object itself.
|
java.lang.String |
getUserFriendlyFieldName(java.lang.String field)
A user-friendly name for the specified field (presumably a field that was found to
be invalid by the CVI).
|
java.lang.String |
getUserFriendlyTypeName()
A user-friendly description of the type of the object.
|
java.util.UUID |
getUuid() |
int |
hashCode()
Overrides
Object.hashCode()
See hibernate109 , geocities
or ibm
for more information about equals and hashcode. |
boolean |
hasListeners(java.lang.String propertyName) |
void |
initListener()
This method was initially added to
CdmBase to fix #5161. |
java.lang.String |
instanceToString()
This returns an String that identifies the cdm instance well without being necessarily unique.
|
protected void |
invokeSetMethod(java.lang.reflect.Method method,
java.lang.Object object) |
protected void |
invokeSetMethodWithNull(java.lang.reflect.Method method,
java.lang.Object object) |
protected boolean |
isBlank(java.lang.String str)
Returns
true if the given String is blank. |
boolean |
isInstanceOf(java.lang.Class<? extends CdmBase> clazz) |
protected boolean |
isNotBlank(java.lang.String str)
Returns
true if the given String is not blank. |
boolean |
isPersited()
Reports the persistend state of the cdm entity.
|
protected <T extends CdmBase> |
removeFromSetWithChangeEvent(java.util.Set<T> set,
T itemToRemove,
java.lang.String propertyName)
Removes an item from a set of
this object and fires the according
PropertyChangeEvent . |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
see
PropertyChangeSupport.addPropertyChangeListener(PropertyChangeListener) |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener) |
protected <T extends CdmBase> |
replaceInList(java.util.List<T> list,
T newObject,
T oldObject) |
void |
setCreated(org.joda.time.DateTime created)
Sets the timestamp this object was created.
|
void |
setCreatedBy(User createdBy) |
void |
setId(int id)
Assigns a unique local ID to this object.
|
static void |
setNewEntityListener(NewEntityListener nel) |
void |
setUuid(java.util.UUID uuid) |
java.lang.String |
toString()
Overrides
Object.toString() . |
protected static final int CLOB_LENGTH
@NotNull @Field(store=YES, index=YES, analyze=NO) @FieldBridge(impl=UuidBridge.class) protected java.util.UUID uuid
public CdmBase()
public static void setNewEntityListener(NewEntityListener nel)
public static void fireOnCreateEvent(CdmBase cdmBase)
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeSupport.addPropertyChangeListener(PropertyChangeListener)
listener
- public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
PropertyChangeSupport.addPropertyChangeListener(String, PropertyChangeListener)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeSupport.addPropertyChangeListener(PropertyChangeListener)
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
PropertyChangeSupport.addPropertyChangeListener(String, PropertyChangeListener)
public boolean hasListeners(java.lang.String propertyName)
public void firePropertyChange(java.lang.String property, java.lang.String oldval, java.lang.String newval)
public void firePropertyChange(java.lang.String property, int oldval, int newval)
public void firePropertyChange(java.lang.String property, float oldval, float newval)
public void firePropertyChange(java.lang.String property, boolean oldval, boolean newval)
public void firePropertyChange(java.lang.String property, java.lang.Object oldval, java.lang.Object newval)
public void firePropertyChange(java.beans.PropertyChangeEvent evt)
public void initListener()
CdmBase
to fix #5161.
It can be overridden by subclasses such as IdentifiableEntity
to explicitly initialize listeners. This is needed e.g. after de-serialization
as listeners are not serialized due to the @Transient annotation.
However, it can be generally used for other use-cases as wellprotected <T extends CdmBase> void addToSetWithChangeEvent(java.util.Set<T> set, T newItem, java.lang.String propertyName)
this
object and fires the according
PropertyChangeEvent
. Workaround as long as add and remove is not yet
implemented in aspectJ.set
- the set the new item is added tonewItem
- the new item to be added to the setpropertyName
- the name of the set as property in this
objectprotected <T extends CdmBase> void removeFromSetWithChangeEvent(java.util.Set<T> set, T itemToRemove, java.lang.String propertyName)
this
object and fires the according
PropertyChangeEvent
. Workaround as long as add and remove is not yet
implemented in aspectJ.set
- the set the item is to be removed fromitemToRemove
- the item to be removed from the setpropertyName
- the name of the set as property in this
objectpublic int getId()
ICdmBase
public void setId(int id)
ICdmBase
public org.joda.time.DateTime getCreated()
getCreated
in interface ICdmBase
public void setCreated(org.joda.time.DateTime created)
ICdmBase
TRAC ticket
setCreated
in interface ICdmBase
public User getCreatedBy()
getCreatedBy
in interface ICdmBase
User
who was authenticated when the entity was created.
Can be null
if the entity has been created without any user authentication present.public void setCreatedBy(User createdBy)
setCreatedBy
in interface ICdmBase
public static <T> T deproxy(T entity)
entity
- java.lang.ClassCastException
public static <T extends CdmBase> T deproxy(java.lang.Object object, java.lang.Class<T> clazz) throws java.lang.ClassCastException
T
- object
- clazz
- java.lang.ClassCastException
public boolean isInstanceOf(java.lang.Class<? extends CdmBase> clazz) throws java.lang.ClassCastException
isInstanceOf
in interface ICdmBase
java.lang.ClassCastException
public boolean isPersited()
ICdmBase
true
it does not
necessarily mean that there is a database record already but
maybe the object was only saved to a persistence session, which still needs to be flushed to the storage engine.isPersited
in interface ICdmBase
public boolean equals(java.lang.Object obj)
true
if UUID and created timestamp (is this really needed/make sense?)
is the same for the passed Object and this one.
This method is final as subclasses should not override it.VersionableEntity.equals(Object)
.
For discussion see #7202.
match strategy
and make sure
matching
is implemented for the respective CdmBase subclass.
You may adapt your match strategy to your own needs.
See hibernate109
, geocities
,
or ibm
for more information about equals and hashcode.
equals
in class java.lang.Object
Object.equals(java.lang.Object)
public int hashCode()
Object.hashCode()
See hibernate109
, geocities
or ibm
for more information about equals and hashcode.hashCode
in class java.lang.Object
public java.lang.String toString()
Object.toString()
.
This returns an String that identifies the object well without being necessarily unique. Internally the method is delegating the
call to {link instanceToString()
.Note: If overriding this method's javadoc always copy or link the above requirement. If not overwritten by a subclass method returns the class, id and uuid as a string for any CDM object.
For example: Taxon#13<b5938a98-c1de-4dda-b040-d5cc5bfb3bc0>
toString
in class java.lang.Object
Object.toString()
public java.lang.String instanceToString()
id
and uuid
.
For example: Taxon#13<b5938a98-c1de-4dda-b040-d5cc5bfb3bc0>
protected void invokeSetMethod(java.lang.reflect.Method method, java.lang.Object object)
protected void invokeSetMethodWithNull(java.lang.reflect.Method method, java.lang.Object object)
public java.lang.String getUserFriendlyTypeName()
ISelfDescriptive
getUserFriendlyTypeName
in interface ISelfDescriptive
public java.lang.String getUserFriendlyDescription()
ISelfDescriptive
Object.toString()
.getUserFriendlyDescription
in interface ISelfDescriptive
public java.lang.String getUserFriendlyFieldName(java.lang.String field)
ISelfDescriptive
getUserFriendlyFieldName
in interface ISelfDescriptive
protected <T extends CdmBase> boolean replaceInList(java.util.List<T> list, T newObject, T oldObject)
protected boolean isBlank(java.lang.String str)
true
if the given String is blank.str
- the String to checktrue
if str is blank, false
otherwiseStringUtils#isBlank(String)
protected boolean isNotBlank(java.lang.String str)
true
if the given String is not blank.str
- the String to checktrue
if str is not blank, false
otherwiseStringUtils#isNotBlank(String)
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
Copyright © 2007-2020 EDIT. All Rights Reserved.