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

com.usefulmilk.support.domain.Entity Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2016 UsefulMilk
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.usefulmilk.support.domain;

/**
 * According to Eric Evans, Entity are objects that have a distinct identity
 * that runs through time and different representations. You also hear these
 * called "reference objects".
 * 

Two different instances of {@link Entity} are equals when the values * returned by {@link Entity#getId()} are equals.

*/ public abstract class Entity extends DomainObject { /** * It compares the {@link Entity#getId()} of parameter object with * this {@link Entity#getId()}. If are equals, it will return true. * @param obj Object to be compared. * @return Return true if the objects are equals. */ @Override public boolean equals(Object obj) { if(obj instanceof Entity) { return idEquals(this, (Entity) obj); } return false; } /** * It will return the hashCode generated by {@link Entity#getId()}. * @return The hashCode of this object. */ @Override public int hashCode() { return getIdHashCode(this); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy