Documented equals dashcode policy
This commit is contained in:
@@ -122,6 +122,13 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined equals/hashcode strategy for the repository in general is that an
|
||||
* entity is equal if it has the same {@link #getId()} and
|
||||
* {@link #getOptLockRevision()} and class.
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() { // NOSONAR - as this is generated code
|
||||
final int prime = 31;
|
||||
@@ -131,6 +138,13 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defined equals/hashcode strategy for the repository in general is that an
|
||||
* entity is equal if it has the same {@link #getId()} and
|
||||
* {@link #getOptLockRevision()} and class.
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||
// code
|
||||
|
||||
@@ -46,10 +46,6 @@ import org.eclipse.persistence.annotations.CascadeOnDelete;
|
||||
* A {@link Target} has exactly one target {@link DistributionSet} assigned.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "sp_distribution_set", uniqueConstraints = {
|
||||
|
||||
@@ -15,9 +15,6 @@ import java.io.Serializable;
|
||||
*
|
||||
*/
|
||||
public class DistributionSetIdName implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Long id;
|
||||
|
||||
@@ -23,10 +23,7 @@ import javax.persistence.ManyToOne;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* Metadata for {@link DistributionSet}.
|
||||
*
|
||||
*
|
||||
*
|
||||
* Meta data for {@link DistributionSet}.
|
||||
*
|
||||
*/
|
||||
@IdClass(DsMetadataCompositeKey.class)
|
||||
|
||||
@@ -14,8 +14,6 @@ import java.io.Serializable;
|
||||
* The DistributionSet Metadata composite key which contains the meta data key
|
||||
* and the ID of the DistributionSet itself.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
public final class DsMetadataCompositeKey implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -22,12 +22,9 @@ import javax.persistence.Table;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* External artifact representation with all the necessray informattion to
|
||||
* External artifact representation with all the necessary information to
|
||||
* generate an artifact {@link URL} at runtime.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Table(name = "sp_external_artifact", indexes = {
|
||||
@Index(name = "sp_idx_external_artifact_prim", columnList = "id,tenant") })
|
||||
|
||||
@@ -60,4 +60,27 @@ public abstract class NamedEntity extends TenantAwareBaseEntity {
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() { // NOSONAR - as this is generated
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + this.getClass().getName().hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (!(obj instanceof NamedEntity)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,12 +33,7 @@ import org.eclipse.persistence.annotations.CascadeOnDelete;
|
||||
|
||||
/**
|
||||
* Base Software Module that is supported by OS level provisioning mechanism on
|
||||
* the edge controller, e.g. OS, JVM, AgentHub
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* the edge controller, e.g. OS, JVM, AgentHub.
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
|
||||
@@ -131,6 +131,12 @@ public class Target extends NamedEntity implements Persistable<Long> {
|
||||
securityToken = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Note: For Target we extended the general strategy by adding controllerId
|
||||
* as well.
|
||||
*
|
||||
* @see org.eclipse.hawkbit.repository.model.BaseEntity#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final Object obj) {// NOSONAR - as this is generated
|
||||
if (this == obj) {
|
||||
|
||||
@@ -21,11 +21,6 @@ import javax.persistence.UniqueConstraint;
|
||||
* A {@link TargetTag} is used to describe Target attributes and use them also
|
||||
* for filtering the target list.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "sp_target_tag", indexes = {
|
||||
|
||||
@@ -75,6 +75,14 @@ public abstract class TenantAwareBaseEntity extends BaseEntity {
|
||||
return "BaseEntity [id=" + super.getId() + "]";
|
||||
}
|
||||
|
||||
/**
|
||||
* Tenant aware entities extend the equals/hashcode strategy with the tenant
|
||||
* name. That would allow for instance in a multi-schema based data
|
||||
* separation setup to have the same primary key for different entities of
|
||||
* different tenants.
|
||||
*
|
||||
* @see org.eclipse.hawkbit.repository.model.BaseEntity#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
@@ -83,6 +91,14 @@ public abstract class TenantAwareBaseEntity extends BaseEntity {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tenant aware entities extend the equals/hashcode strategy with the tenant
|
||||
* name. That would allow for instance in a multi-schema based data
|
||||
* separation setup to have the same primary key for different entities of
|
||||
* different tenants.
|
||||
*
|
||||
* @see org.eclipse.hawkbit.repository.model.BaseEntity#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
|
||||
@@ -19,9 +19,6 @@ import javax.persistence.UniqueConstraint;
|
||||
/**
|
||||
* A JPA entity which stores the tenant specific configuration.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Entity
|
||||
@Table(name = "sp_tenant_configuration", uniqueConstraints = @UniqueConstraint(columnNames = { "conf_key",
|
||||
@@ -88,31 +85,23 @@ public class TenantConfiguration extends TenantAwareBaseEntity implements Serial
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (key == null ? 0 : key.hashCode());
|
||||
int result = super.hashCode();
|
||||
result = prime * result + this.getClass().getName().hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||
// code
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
if (!super.equals(obj)) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final TenantConfiguration other = (TenantConfiguration) obj;
|
||||
if (key == null) {
|
||||
if (other.key != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!key.equals(other.key)) {
|
||||
if (!(obj instanceof TenantConfiguration)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user