ForeignKey.java
// license-header java merge-point
//
/**
* @author Generated on 09/21/2012 13:39:17-0400 Do not modify by hand!
*
* TEMPLATE: ValueObject.vsl in andromda-java-cartridge.
* MODEL CLASS: JDBCMetadataModel::org.andromda.jdbcmetadata::ForeignKey
* STEREOTYPE: ValueObject
*/
package org.andromda.jdbcmetadata;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
* <p>All defined Foreign Key Constraints for a table. PK table FK(columns) references FK table
* (columns), i.e. from command</p><p>ALTER TABLE txn_evt_rsn ADD CONSTRAINT
* txn_evt_rsn_c2</p><p>FOREIGN KEY (txn_evt_typ_nm, txn_evt_vl_nm,
* txn_evt_rsn_vl_id)</p><p>REFERENCES txn_evt_rsn_assc(txn_evt_typ_nm, txn_evt_vl_nm,
* txn_evt_rsn_vl_id);</p><p>A FK has one PK table and one FK table. A table has one PK, but may
* have multiple FKs.</p><p>This corresponds to one Association relationship between two entities,
* even with a composite key of multiple columns.</p>
*/
public class ForeignKey
implements Serializable, Comparable<ForeignKey>
{
/** The serial version UID of this class. Needed for serialization. */
private static final long serialVersionUID = -4080540880780814899L;
// Class attributes
/**
* <p>The name of the Foreign Key</p>
*/
protected String fkName;
/**
* <p>The name of the primary key referenced by the foreign key</p>
*/
protected String pkName;
/**
* <p>The name of the primary key referenced by the foreign key</p>
*/
protected String pkUmlPropertyName;
/**
* <p>The name of the Foreign Key</p>
*/
protected String fkUmlPropertyName;
/**
* <p>(Optional) Whether the column relationship is one to one from this FK table to the related
* PK table - when the fk columns are the same as the PK columns for the table. By default
* relationships are one to many.</p>
*/
protected boolean oneToOne = false;
/**
* boolean setter for primitive attribute, so we can tell if it's initialized
*/
protected boolean setOneToOne = false;
/**
* <p>(Optional) Whether the column relationship is navigable from this FK property to the
* related PK property in the other entity. By default relationships are bidirectional -
* navigable in both directions, setting to false results in a uni-directional association.</p>
*/
protected boolean navigableFK = true;
/**
* boolean setter for primitive attribute, so we can tell if it's initialized
*/
protected boolean setNavigableFK = false;
/**
* <p>(Optional) Whether the column relationship is navigable from this PK property to the
* related FK property in the other entity. By default relationships are bidirectional -
* navigable in both directions, setting to false results in a uni-directional association.</p>
*/
protected boolean navigablePK = true;
/**
* boolean setter for primitive attribute, so we can tell if it's initialized
*/
protected boolean setNavigablePK = false;
/**
* <p>TheUML Aggregation Type (Shared = open diamond, Composite = black diamond, None) on the FK
* owning side of the association relationship. In AndroMDA this determines the default cascade
* type.</p>
*/
protected AggregationType aggregationFK;
/**
* <p>TheUML Aggregation Type (Shared = open diamond, Composite = black diamond, None) on the PK
* non-owning side of the association relationship. In AndroMDA this determines the default
* cascade type.</p>
*/
protected AggregationType aggregationPK;
/**
* <p>The update rule (action taken) for the FK when the PK value is updated.</p>
*/
protected CascadeType updateRule;
/**
* <p>The delete rule (action taken) for the FK when the PK value is deleted.</p>
*/
protected CascadeType deleteRule;
// Class associationEnds
/**
* <p>The FKColumns (sequences of Column) in the FK</p>
*/
protected List<FKColumn> columns;
/**
* <p>The PK Table referenced by this FK.</p>
*/
protected Table referencedTable;
/**
* <p>The table with the FK.</p>
*/
protected Table fkTable;
/** Default Constructor with no properties */
public ForeignKey()
{
// Documented empty block - avoid compiler warning - no super constructor
}
/**
* Constructor taking only required properties
* @param fkNameIn String <p>The name of the Foreign Key</p>
* @param pkNameIn String <p>The name of the primary key referenced by the foreign key</p>
* @param pkUmlPropertyNameIn String <p>The name of the primary key referenced by the foreign key</p>
* @param fkUmlPropertyNameIn String <p>The name of the Foreign Key</p>
* @param oneToOneIn boolean <p>(Optional) Whether the column relationship is one to one from this FK table to the related PK
table - when the fk columns are the same as the PK columns for the table. By default relationships
are one to many.</p>
* @param navigableFKIn boolean <p>(Optional) Whether the column relationship is navigable from this FK property to the related PK
property in the other entity. By default relationships are bidirectional - navigable in both
directions, setting to false results in a uni-directional association.</p>
* @param navigablePKIn boolean <p>(Optional) Whether the column relationship is navigable from this PK property to the related FK
property in the other entity. By default relationships are bidirectional - navigable in both
directions, setting to false results in a uni-directional association.</p>
* @param updateRuleIn CascadeType <p>The update rule (action taken) for the FK when the PK value is updated.</p>
* @param deleteRuleIn CascadeType <p>The delete rule (action taken) for the FK when the PK value is deleted.</p>
* @param columnsIn List<FKColumn> <p>The FKColumns (sequences of Column) in the FK</p>
* @param referencedTableIn Table <p>The PK Table referenced by this FK.</p>
* @param fkTableIn Table <p>The table with the FK.</p>
*/
public ForeignKey(final String fkNameIn, final String pkNameIn, final String pkUmlPropertyNameIn, final String fkUmlPropertyNameIn, final boolean oneToOneIn, final boolean navigableFKIn, final boolean navigablePKIn, final CascadeType updateRuleIn, final CascadeType deleteRuleIn, final List<FKColumn> columnsIn, final Table referencedTableIn, final Table fkTableIn)
{
this.fkName = fkNameIn;
this.pkName = pkNameIn;
this.pkUmlPropertyName = pkUmlPropertyNameIn;
this.fkUmlPropertyName = fkUmlPropertyNameIn;
this.oneToOne = oneToOneIn;
this.setOneToOne = true;
this.navigableFK = navigableFKIn;
this.setNavigableFK = true;
this.navigablePK = navigablePKIn;
this.setNavigablePK = true;
this.updateRule = updateRuleIn;
this.deleteRule = deleteRuleIn;
this.columns = columnsIn;
this.referencedTable = referencedTableIn;
this.fkTable = fkTableIn;
}
/**
* Constructor with all properties
* @param fkNameIn String
* @param pkNameIn String
* @param pkUmlPropertyNameIn String
* @param fkUmlPropertyNameIn String
* @param oneToOneIn boolean
* @param navigableFKIn boolean
* @param navigablePKIn boolean
* @param aggregationFKIn AggregationType
* @param aggregationPKIn AggregationType
* @param updateRuleIn CascadeType
* @param deleteRuleIn CascadeType
* @param columnsIn List<FKColumn>
* @param referencedTableIn Table
* @param fkTableIn Table
*/
public ForeignKey(final String fkNameIn, final String pkNameIn, final String pkUmlPropertyNameIn, final String fkUmlPropertyNameIn, final boolean oneToOneIn, final boolean navigableFKIn, final boolean navigablePKIn, final AggregationType aggregationFKIn, final AggregationType aggregationPKIn, final CascadeType updateRuleIn, final CascadeType deleteRuleIn, final List<FKColumn> columnsIn, final Table referencedTableIn, final Table fkTableIn)
{
this.fkName = fkNameIn;
this.pkName = pkNameIn;
this.pkUmlPropertyName = pkUmlPropertyNameIn;
this.fkUmlPropertyName = fkUmlPropertyNameIn;
this.oneToOne = oneToOneIn;
this.setOneToOne = true;
this.navigableFK = navigableFKIn;
this.setNavigableFK = true;
this.navigablePK = navigablePKIn;
this.setNavigablePK = true;
this.aggregationFK = aggregationFKIn;
this.aggregationPK = aggregationPKIn;
this.updateRule = updateRuleIn;
this.deleteRule = deleteRuleIn;
this.columns = columnsIn;
this.referencedTable = referencedTableIn;
this.fkTable = fkTableIn;
}
/**
* Copies constructor from other ForeignKey
*
* @param otherBean Cannot be <code>null</code>
* @throws NullPointerException if the argument is <code>null</code>
*/
public ForeignKey(final ForeignKey otherBean)
{
this.fkName = otherBean.getFkName();
this.pkName = otherBean.getPkName();
this.pkUmlPropertyName = otherBean.getPkUmlPropertyName();
this.fkUmlPropertyName = otherBean.getFkUmlPropertyName();
this.oneToOne = otherBean.isOneToOne();
this.setOneToOne = true;
this.navigableFK = otherBean.isNavigableFK();
this.setNavigableFK = true;
this.navigablePK = otherBean.isNavigablePK();
this.setNavigablePK = true;
this.aggregationFK = otherBean.getAggregationFK();
this.aggregationPK = otherBean.getAggregationPK();
this.updateRule = otherBean.getUpdateRule();
this.deleteRule = otherBean.getDeleteRule();
this.columns = otherBean.getColumns();
this.referencedTable = otherBean.getReferencedTable();
this.fkTable = otherBean.getFkTable();
}
/**
* Copies all properties from the argument value object into this value object.
* @param otherBean Cannot be <code>null</code>
*/
public void copy(final ForeignKey otherBean)
{
if (null != otherBean)
{
this.setFkName(otherBean.getFkName());
this.setPkName(otherBean.getPkName());
this.setPkUmlPropertyName(otherBean.getPkUmlPropertyName());
this.setFkUmlPropertyName(otherBean.getFkUmlPropertyName());
this.setOneToOne(otherBean.isOneToOne());
this.setOneToOne = true;
this.setNavigableFK(otherBean.isNavigableFK());
this.setNavigableFK = true;
this.setNavigablePK(otherBean.isNavigablePK());
this.setNavigablePK = true;
this.setAggregationFK(otherBean.getAggregationFK());
this.setAggregationPK(otherBean.getAggregationPK());
this.setUpdateRule(otherBean.getUpdateRule());
this.setDeleteRule(otherBean.getDeleteRule());
this.setColumns(otherBean.getColumns());
this.setReferencedTable(otherBean.getReferencedTable());
this.setFkTable(otherBean.getFkTable());
}
}
/**
* <p>The name of the Foreign Key</p>
* Get the fkName Attribute
* @return fkName String
*/
public String getFkName()
{
return this.fkName;
}
/**
* <p>The name of the Foreign Key</p>
* @param value String
*/
public void setFkName(final String value)
{
this.fkName = value;
}
/**
* <p>The name of the primary key referenced by the foreign key</p>
* Get the pkName Attribute
* @return pkName String
*/
public String getPkName()
{
return this.pkName;
}
/**
* <p>The name of the primary key referenced by the foreign key</p>
* @param value String
*/
public void setPkName(final String value)
{
this.pkName = value;
}
/**
* <p>The name of the primary key referenced by the foreign key</p>
* Get the pkUmlPropertyName Attribute
* @return pkUmlPropertyName String
*/
public String getPkUmlPropertyName()
{
return this.pkUmlPropertyName;
}
/**
* <p>The name of the primary key referenced by the foreign key</p>
* @param value String
*/
public void setPkUmlPropertyName(final String value)
{
this.pkUmlPropertyName = value;
}
/**
* <p>The name of the Foreign Key</p>
* Get the fkUmlPropertyName Attribute
* @return fkUmlPropertyName String
*/
public String getFkUmlPropertyName()
{
return this.fkUmlPropertyName;
}
/**
* <p>The name of the Foreign Key</p>
* @param value String
*/
public void setFkUmlPropertyName(final String value)
{
this.fkUmlPropertyName = value;
}
/**
* <p>(Optional) Whether the column relationship is one to one from this FK table to the related
* PK table - when the fk columns are the same as the PK columns for the table. By default
* relationships are one to many.</p>
* Get the oneToOne Attribute
* @return oneToOne boolean
*/
public boolean isOneToOne()
{
return this.oneToOne;
}
/**
* <p>(Optional) Whether the column relationship is one to one from this FK table to the related
* PK table - when the fk columns are the same as the PK columns for the table. By default
* relationships are one to many.</p>
* Duplicates isBoolean method, for use as Jaxb2 compatible object
* Get the oneToOne Attribute
* @return oneToOne boolean
*/
@Deprecated
public boolean getOneToOne()
{
return this.oneToOne;
}
/**
* <p>(Optional) Whether the column relationship is one to one from this FK table to the related
* PK table - when the fk columns are the same as the PK columns for the table. By default
* relationships are one to many.</p>
* @param value boolean
*/
public void setOneToOne(final boolean value)
{
this.oneToOne = value;
this.setOneToOne = true;
}
/**
* Return true if the primitive attribute oneToOne is set, through the setter or constructor
* @return true if the attribute value has been set
*/
public boolean isSetOneToOne()
{
return this.setOneToOne;
}
/**
* <p>(Optional) Whether the column relationship is navigable from this FK property to the
* related PK property in the other entity. By default relationships are bidirectional -
* navigable in both directions, setting to false results in a uni-directional association.</p>
* Get the navigableFK Attribute
* @return navigableFK boolean
*/
public boolean isNavigableFK()
{
return this.navigableFK;
}
/**
* <p>(Optional) Whether the column relationship is navigable from this FK property to the
* related PK property in the other entity. By default relationships are bidirectional -
* navigable in both directions, setting to false results in a uni-directional association.</p>
* Duplicates isBoolean method, for use as Jaxb2 compatible object
* Get the navigableFK Attribute
* @return navigableFK boolean
*/
@Deprecated
public boolean getNavigableFK()
{
return this.navigableFK;
}
/**
* <p>(Optional) Whether the column relationship is navigable from this FK property to the
* related PK property in the other entity. By default relationships are bidirectional -
* navigable in both directions, setting to false results in a uni-directional association.</p>
* @param value boolean
*/
public void setNavigableFK(final boolean value)
{
this.navigableFK = value;
this.setNavigableFK = true;
}
/**
* Return true if the primitive attribute navigableFK is set, through the setter or constructor
* @return true if the attribute value has been set
*/
public boolean isSetNavigableFK()
{
return this.setNavigableFK;
}
/**
* <p>(Optional) Whether the column relationship is navigable from this PK property to the
* related FK property in the other entity. By default relationships are bidirectional -
* navigable in both directions, setting to false results in a uni-directional association.</p>
* Get the navigablePK Attribute
* @return navigablePK boolean
*/
public boolean isNavigablePK()
{
return this.navigablePK;
}
/**
* <p>(Optional) Whether the column relationship is navigable from this PK property to the
* related FK property in the other entity. By default relationships are bidirectional -
* navigable in both directions, setting to false results in a uni-directional association.</p>
* Duplicates isBoolean method, for use as Jaxb2 compatible object
* Get the navigablePK Attribute
* @return navigablePK boolean
*/
@Deprecated
public boolean getNavigablePK()
{
return this.navigablePK;
}
/**
* <p>(Optional) Whether the column relationship is navigable from this PK property to the
* related FK property in the other entity. By default relationships are bidirectional -
* navigable in both directions, setting to false results in a uni-directional association.</p>
* @param value boolean
*/
public void setNavigablePK(final boolean value)
{
this.navigablePK = value;
this.setNavigablePK = true;
}
/**
* Return true if the primitive attribute navigablePK is set, through the setter or constructor
* @return true if the attribute value has been set
*/
public boolean isSetNavigablePK()
{
return this.setNavigablePK;
}
/**
* <p>TheUML Aggregation Type (Shared = open diamond, Composite = black diamond, None) on the FK
* owning side of the association relationship. In AndroMDA this determines the default cascade
* type.</p>
* Get the aggregationFK Attribute
* @return aggregationFK AggregationType
*/
public AggregationType getAggregationFK()
{
return this.aggregationFK;
}
/**
* <p>TheUML Aggregation Type (Shared = open diamond, Composite = black diamond, None) on the FK
* owning side of the association relationship. In AndroMDA this determines the default cascade
* type.</p>
* @param value AggregationType
*/
public void setAggregationFK(final AggregationType value)
{
this.aggregationFK = value;
}
/**
* <p>TheUML Aggregation Type (Shared = open diamond, Composite = black diamond, None) on the PK
* non-owning side of the association relationship. In AndroMDA this determines the default
* cascade type.</p>
* Get the aggregationPK Attribute
* @return aggregationPK AggregationType
*/
public AggregationType getAggregationPK()
{
return this.aggregationPK;
}
/**
* <p>TheUML Aggregation Type (Shared = open diamond, Composite = black diamond, None) on the PK
* non-owning side of the association relationship. In AndroMDA this determines the default
* cascade type.</p>
* @param value AggregationType
*/
public void setAggregationPK(final AggregationType value)
{
this.aggregationPK = value;
}
/**
* <p>The update rule (action taken) for the FK when the PK value is updated.</p>
* Get the updateRule Attribute
* @return updateRule CascadeType
*/
public CascadeType getUpdateRule()
{
return this.updateRule;
}
/**
* <p>The update rule (action taken) for the FK when the PK value is updated.</p>
* @param value CascadeType
*/
public void setUpdateRule(final CascadeType value)
{
this.updateRule = value;
}
/**
* <p>The delete rule (action taken) for the FK when the PK value is deleted.</p>
* Get the deleteRule Attribute
* @return deleteRule CascadeType
*/
public CascadeType getDeleteRule()
{
return this.deleteRule;
}
/**
* <p>The delete rule (action taken) for the FK when the PK value is deleted.</p>
* @param value CascadeType
*/
public void setDeleteRule(final CascadeType value)
{
this.deleteRule = value;
}
/**
* <p>The FKColumns (sequences of Column) in the FK</p>
* Get the columns Association
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the object.
* @return this.columns List<FKColumn>
*/
public List<FKColumn> getColumns()
{
if (this.columns == null)
{
this.columns = new ArrayList<FKColumn>();
}
return this.columns;
}
/**
* Sets the columns
* @param value List<FKColumn>
*/
public void setColumns(List<FKColumn> value)
{
this.columns = value;
}
/**
* <p>The PK Table referenced by this FK.</p>
* Get the referencedTable Association
* @return this.referencedTable Table
*/
public Table getReferencedTable()
{
return this.referencedTable;
}
/**
* Sets the referencedTable
* @param value Table
*/
public void setReferencedTable(Table value)
{
this.referencedTable = value;
}
/**
* <p>The table with the FK.</p>
* Get the fkTable Association
* @return this.fkTable Table
*/
public Table getFkTable()
{
return this.fkTable;
}
/**
* Sets the fkTable
* @param value Table
*/
public void setFkTable(Table value)
{
this.fkTable = value;
}
/**
* @param object to compare this object against
* @return boolean if equal
* @see Object#equals(Object)
*/
@Override
public boolean equals(final Object object)
{
if (object==null || object.getClass() != this.getClass())
{
return false;
}
// Check if the same object instance
if (object==this)
{
return true;
}
ForeignKey rhs = (ForeignKey) object;
return new EqualsBuilder()
.append(this.getFkName(), rhs.getFkName())
.append(this.getPkName(), rhs.getPkName())
.append(this.getPkUmlPropertyName(), rhs.getPkUmlPropertyName())
.append(this.getFkUmlPropertyName(), rhs.getFkUmlPropertyName())
.append(this.isOneToOne(), rhs.isOneToOne())
.append(this.isNavigableFK(), rhs.isNavigableFK())
.append(this.isNavigablePK(), rhs.isNavigablePK())
.append(this.getAggregationFK(), rhs.getAggregationFK())
.append(this.getAggregationPK(), rhs.getAggregationPK())
.append(this.getUpdateRule(), rhs.getUpdateRule())
.append(this.getDeleteRule(), rhs.getDeleteRule())
.append(this.getColumns(), rhs.getColumns())
.append(this.getReferencedTable(), rhs.getReferencedTable())
.append(this.getFkTable(), rhs.getFkTable())
.isEquals();
}
/**
* @param object to compare this object against
* @return int if equal
* @see Comparable#compareTo(Object)
*/
public int compareTo(final ForeignKey object)
{
if (object==null)
{
return -1;
}
// Check if the same object instance
if (object==this)
{
return 0;
}
return new CompareToBuilder()
.append(this.getFkName(), object.getFkName())
.append(this.getPkName(), object.getPkName())
.append(this.getPkUmlPropertyName(), object.getPkUmlPropertyName())
.append(this.getFkUmlPropertyName(), object.getFkUmlPropertyName())
.append(this.isOneToOne(), object.isOneToOne())
.append(this.isNavigableFK(), object.isNavigableFK())
.append(this.isNavigablePK(), object.isNavigablePK())
.append(this.getAggregationFK(), object.getAggregationFK())
.append(this.getAggregationPK(), object.getAggregationPK())
.append(this.getUpdateRule(), object.getUpdateRule())
.append(this.getDeleteRule(), object.getDeleteRule())
.append(this.getColumns(), object.getColumns())
.append(this.getReferencedTable(), object.getReferencedTable())
.append(this.getFkTable(), object.getFkTable())
.toComparison();
}
/**
* @return int hashCode value
* @see Object#hashCode()
*/
@Override
public int hashCode()
{
return new HashCodeBuilder(1249046965, -82296885)
.append(this.getFkName())
.append(this.getPkName())
.append(this.getPkUmlPropertyName())
.append(this.getFkUmlPropertyName())
.append(this.isOneToOne())
.append(this.isNavigableFK())
.append(this.isNavigablePK())
.append(this.getAggregationFK())
.append(this.getAggregationPK())
.append(this.getUpdateRule())
.append(this.getDeleteRule())
//Commented out to avoid commons-lang-2.4 recursion StackOverflowError: https://issues.apache.org/jira/browse/LANG-456
//.append(this.getColumns())
.append(this.getReferencedTable())
.append(this.getFkTable())
.toHashCode();
}
/**
* @return String representation of object
* @see Object#toString()
*/
@Override
public String toString()
{
return new ToStringBuilder(this)
.append("fkName", this.getFkName())
.append("pkName", this.getPkName())
.append("pkUmlPropertyName", this.getPkUmlPropertyName())
.append("fkUmlPropertyName", this.getFkUmlPropertyName())
.append("oneToOne", this.isOneToOne())
.append("navigableFK", this.isNavigableFK())
.append("navigablePK", this.isNavigablePK())
.append("aggregationFK", this.getAggregationFK())
.append("aggregationPK", this.getAggregationPK())
.append("updateRule", this.getUpdateRule())
.append("deleteRule", this.getDeleteRule())
.append("columns", this.getColumns())
.append("referencedTable", this.getReferencedTable())
.append("fkTable", this.getFkTable())
.toString();
}
/**
* Compares the properties of this instance to the properties of the argument. This method will return
* {@code false} as soon as it detects that the argument is {@code null} or not of the same type as
* (or a sub-type of) this instance's type.
*
* <p/>For array, collection or map properties the comparison will be done one level deep, in other words:
* the elements will be compared using the {@code equals()} operation.
*
* <p/>Note that two properties will be considered equal when both values are {@code null}.
*
* @param thatObject the object containing the properties to compare against this instance
* @return this method will return {@code true} in case the argument has the same type as this class, or is a
* sub-type of this class and all properties as found on this class have equal values when queried on that
* argument instance; in all other cases this method will return {@code false}
*/
public boolean equalProperties(final Object thatObject)
{
if (thatObject == null || !this.getClass().isAssignableFrom(thatObject.getClass()))
{
return false;
}
final ForeignKey that = (ForeignKey)thatObject;
return
equal(this.getFkName(), that.getFkName())
&& equal(this.getPkName(), that.getPkName())
&& equal(this.getPkUmlPropertyName(), that.getPkUmlPropertyName())
&& equal(this.getFkUmlPropertyName(), that.getFkUmlPropertyName())
&& equal(this.isOneToOne(), that.isOneToOne())
&& equal(this.isNavigableFK(), that.isNavigableFK())
&& equal(this.isNavigablePK(), that.isNavigablePK())
&& equal(this.getAggregationFK(), that.getAggregationFK())
&& equal(this.getAggregationPK(), that.getAggregationPK())
&& equal(this.getUpdateRule(), that.getUpdateRule())
&& equal(this.getDeleteRule(), that.getDeleteRule())
&& equal(this.getColumns(), that.getColumns())
&& equal(this.getReferencedTable(), that.getReferencedTable())
&& equal(this.getFkTable(), that.getFkTable())
;
}
/**
* This is a convenient helper method which is able to detect whether or not two values are equal. Two values
* are equal when they are both {@code null}, are arrays of the same length with equal elements or are
* equal objects (this includes {@link java.util.Collection} and {@link java.util.Map} instances).
*
* <p/>Note that for array, collection or map instances the comparison runs one level deep.
*
* @param first the first object to compare, may be {@code null}
* @param second the second object to compare, may be {@code null}
* @return this method will return {@code true} in case both objects are equal as explained above;
* in all other cases this method will return {@code false}
*/
protected static boolean equal(final Object first, final Object second)
{
final boolean equal;
if (first == null)
{
equal = (second == null);
}
else if (first.getClass().isArray() && (second != null) && second.getClass().isArray())
{
equal = Arrays.equals((Object[])first, (Object[])second);
}
else // note that the following also covers java.util.Collection and java.util.Map
{
equal = first.equals(second);
}
return equal;
}
// ForeignKey value-object java merge-point
}