/*
* This file is part of rockframework.
*
* rockframework is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* rockframework is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>;.
*/
package br.net.woodstock.rockframework.domain.persistence;
import java.io.Serializable;
import br.net.woodstock.rockframework.core.RockFrameworkVersion;
import br.net.woodstock.rockframework.core.util.EqualsBuilder;
import br.net.woodstock.rockframework.core.util.HashCodeBuilder;
import br.net.woodstock.rockframework.core.util.ToStringBuilder;
import br.net.woodstock.rockframework.domain.Entity;
public abstract class AbstractEntity<T extends Serializable> implements Entity<T> {
private static final long serialVersionUID = RockFrameworkVersion.VERSION;
public AbstractEntity() {
super();
}
public AbstractEntity(final T id) {
super();
this.setId(id);
}
@Override
@SuppressWarnings("unchecked")
public boolean equals(final Object obj) {
if (!(obj instanceof AbstractEntity)) {
return false;
}
AbstractEntity<T> other = (AbstractEntity<T>) obj;
return new EqualsBuilder().add(this.getId(), other.getId()).build().booleanValue();
}
@Override
public int hashCode() {
return new HashCodeBuilder().add(this.getId()).build().intValue();
}
@Override
public String toString() {
return new ToStringBuilder(this.getClass()).add("id", this.getId()).build();
}
}