com.github.adminfaces.persistence.model.BaseEntity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of admin-persistence Show documentation
Show all versions of admin-persistence Show documentation
Provides CRUD utilities for CDI, JPA and JSF based applications.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.github.adminfaces.persistence.model;
import java.io.Serializable;
/**
*
* @author rmpestano
*/
public abstract class BaseEntity implements PersistenceEntity {
public abstract ID getId();
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
BaseEntity other = (BaseEntity) obj;
if (getId() == null) {
if (other.getId() != null) {
return false;
}
} else if (!getId().equals(other.getId())) {
return false;
}
return true;
}
@Override
public String toString() {
return String.format("%s[id=%d]", getClass().getSimpleName(), getId());
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy