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

src.samples.java.ex.CHBH_HashcodeToHashcodeSample Maven / Gradle / Ivy

Go to download

An auxiliary findbugs.sourceforge.net plugin for java bug detectors that fall outside the narrow scope of detectors to be packaged with the product itself.

The newest version!
package ex;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

public class CHBH_HashcodeToHashcodeSample {
    public final String name;
    public final int age;

    CHBH_HashcodeToHashcodeSample(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder().append(name).append(age).hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        CHBH_HashcodeToHashcodeSample other = (CHBH_HashcodeToHashcodeSample) obj;
        return new EqualsBuilder().append(this.name, other.name).append(this.age, other.age).isEquals();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy