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

com.ajjpj.abase.collection.AEqualsWrapper Maven / Gradle / Ivy

Go to download

a-base is a library of basic (hence the name) classes, most notably immutable collection classes with copy-on-write operations

There is a newer version: 1.0-pre11
Show newest version
package com.ajjpj.abase.collection;


import java.io.Serializable;


/**
 * This class wraps arbitrary objects, providing customizable equals() and hashCode() behavior based
 *  on an AEquality instance. Calls to equals() or hashCode() on the wrapper are delegated
 *  to the corresponding calls on the AEquality instance. 

* * This is a rather low-level class that is primarily useful for infrstructure code. If you do not understand its usefulness, you * probably do not need it. * * @author arno */ public class AEqualsWrapper implements Serializable { //TODO junit final AEquality equality; public final T value; public AEqualsWrapper(AEquality equality, T value) { this.equality = equality; this.value = value; } @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") @Override public boolean equals(Object obj) { return equality.equals(value, ((AEqualsWrapper)obj).value); } @Override public int hashCode() { return equality.hashCode(value); } @Override public String toString() { return value.toString(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy