
com.puresoltechnologies.commons.ddd.AbstractEntity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ddd Show documentation
Show all versions of ddd Show documentation
Contents of this package is an experimental setup of interfaces and
abstract classes to help development in Domain Driven Design.
The newest version!
package com.puresoltechnologies.commons.ddd;
/**
* This is an abstract implementation of an {@link Entity}.
*
* @author Rick-Rainer Ludwig
*
* @param
* is the actual type of the id.
*/
public class AbstractEntity implements Entity {
private final I id;
public AbstractEntity(I id) {
super();
this.id = id;
}
@Override
public final I getId() {
return id;
}
@Override
public final int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public final boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AbstractEntity> other = (AbstractEntity>) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy