Documented equals dashcode policy
This commit is contained in:
@@ -122,6 +122,13 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
|||||||
this.id = id;
|
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
|
@Override
|
||||||
public int hashCode() { // NOSONAR - as this is generated code
|
public int hashCode() { // NOSONAR - as this is generated code
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -131,6 +138,13 @@ public abstract class BaseEntity implements Serializable, Identifiable<Long> {
|
|||||||
return result;
|
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
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
||||||
// code
|
// code
|
||||||
|
|||||||
@@ -46,10 +46,6 @@ import org.eclipse.persistence.annotations.CascadeOnDelete;
|
|||||||
* A {@link Target} has exactly one target {@link DistributionSet} assigned.
|
* A {@link Target} has exactly one target {@link DistributionSet} assigned.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_distribution_set", uniqueConstraints = {
|
@Table(name = "sp_distribution_set", uniqueConstraints = {
|
||||||
|
|||||||
@@ -15,9 +15,6 @@ import java.io.Serializable;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class DistributionSetIdName implements Serializable {
|
public class DistributionSetIdName implements Serializable {
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final Long id;
|
private final Long id;
|
||||||
|
|||||||
@@ -23,10 +23,7 @@ import javax.persistence.ManyToOne;
|
|||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Metadata for {@link DistributionSet}.
|
* Meta data for {@link DistributionSet}.
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@IdClass(DsMetadataCompositeKey.class)
|
@IdClass(DsMetadataCompositeKey.class)
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ import java.io.Serializable;
|
|||||||
* The DistributionSet Metadata composite key which contains the meta data key
|
* The DistributionSet Metadata composite key which contains the meta data key
|
||||||
* and the ID of the DistributionSet itself.
|
* and the ID of the DistributionSet itself.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public final class DsMetadataCompositeKey implements Serializable {
|
public final class DsMetadataCompositeKey implements Serializable {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|||||||
@@ -22,12 +22,9 @@ import javax.persistence.Table;
|
|||||||
import javax.validation.constraints.NotNull;
|
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.
|
* generate an artifact {@link URL} at runtime.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Table(name = "sp_external_artifact", indexes = {
|
@Table(name = "sp_external_artifact", indexes = {
|
||||||
@Index(name = "sp_idx_external_artifact_prim", columnList = "id,tenant") })
|
@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) {
|
public void setName(final String name) {
|
||||||
this.name = 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
|
* 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
|
@Entity
|
||||||
|
|||||||
@@ -131,6 +131,12 @@ public class Target extends NamedEntity implements Persistable<Long> {
|
|||||||
securityToken = null;
|
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
|
@Override
|
||||||
public boolean equals(final Object obj) {// NOSONAR - as this is generated
|
public boolean equals(final Object obj) {// NOSONAR - as this is generated
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
|
|||||||
@@ -21,11 +21,6 @@ import javax.persistence.UniqueConstraint;
|
|||||||
* A {@link TargetTag} is used to describe Target attributes and use them also
|
* A {@link TargetTag} is used to describe Target attributes and use them also
|
||||||
* for filtering the target list.
|
* for filtering the target list.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_target_tag", indexes = {
|
@Table(name = "sp_target_tag", indexes = {
|
||||||
|
|||||||
@@ -75,6 +75,14 @@ public abstract class TenantAwareBaseEntity extends BaseEntity {
|
|||||||
return "BaseEntity [id=" + super.getId() + "]";
|
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
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
@@ -83,6 +91,14 @@ public abstract class TenantAwareBaseEntity extends BaseEntity {
|
|||||||
return result;
|
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
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
|
|||||||
@@ -19,9 +19,6 @@ import javax.persistence.UniqueConstraint;
|
|||||||
/**
|
/**
|
||||||
* A JPA entity which stores the tenant specific configuration.
|
* A JPA entity which stores the tenant specific configuration.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "sp_tenant_configuration", uniqueConstraints = @UniqueConstraint(columnNames = { "conf_key",
|
@Table(name = "sp_tenant_configuration", uniqueConstraints = @UniqueConstraint(columnNames = { "conf_key",
|
||||||
@@ -88,31 +85,23 @@ public class TenantConfiguration extends TenantAwareBaseEntity implements Serial
|
|||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = super.hashCode();
|
||||||
result = prime * result + (key == null ? 0 : key.hashCode());
|
result = prime * result + this.getClass().getName().hashCode();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) { // NOSONAR - as this is generated
|
public boolean equals(final Object obj) {
|
||||||
// code
|
|
||||||
if (this == obj) {
|
if (this == obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj == null) {
|
if (!super.equals(obj)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (getClass() != obj.getClass()) {
|
if (!(obj instanceof TenantConfiguration)) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final TenantConfiguration other = (TenantConfiguration) obj;
|
|
||||||
if (key == null) {
|
|
||||||
if (other.key != null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else if (!key.equals(other.key)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user