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

org.organicdesign.fp.collections.AbstractUnmodSet Maven / Gradle / Ivy

package org.organicdesign.fp.collections;

import java.util.Set;

/**
 Implements equals and hashCode() methods compatible with java.util.Set (which ignores order)
 to make defining unmod sets easier, especially for implementing Map.keySet() and such.
 */
public abstract class AbstractUnmodSet extends AbstractUnmodIterable implements UnmodSet {
    @Override public boolean equals(Object other) {
        if (this == other) { return true; }
        if ( !(other instanceof Set) ) { return false; }
        Set that = (Set) other;
        return (size() == that.size()) &&
               containsAll(that);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy