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

jedi.example.EqualsAndHashcode Maven / Gradle / Ivy

There is a newer version: 3.0.5
Show newest version
package jedi.example;

import java.util.Date;

import static jedi.option.Options.option;

public class EqualsAndHashcode {
    private String f = "something";
    private Date d = new Date();

    @Override
    public int hashCode() {
        return option(f).hashCode() ^ option(d).hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == this) return true;
        if (obj == null || !(obj instanceof EqualsAndHashcode)) return false;

        EqualsAndHashcode o = (EqualsAndHashcode) obj;
        // no need for null checks. Note that Some(x).equals((Some(y)) == x.equals(y) and None == None
        return option(f).equals(option(o.f)) && option(d).equals(option(o.d));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy