All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.adminfaces.persistence.model.BaseEntity Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
/*
 * 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