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

org.yarnandtail.andhow.PropertyValue Maven / Gradle / Ivy

There is a newer version: 1.5.0
Show newest version
package org.yarnandtail.andhow;

import org.yarnandtail.andhow.api.Property;

/**
 * Simple class to bundle a Property and value.
 * 
 * @author eeverman
 */
public class PropertyValue {

	private final Property property;
	private final T value;

	@Override
	public boolean equals(Object obj) {
		boolean basicPropsEq = false;
		
		if (obj instanceof PropertyValue) {
			PropertyValue other = (PropertyValue)obj;
			if (property == other.property) {
				if (value != null && other.value != null) {
					basicPropsEq = (value.equals(other.value));
				} else if (value == null && other.value == null) {
					basicPropsEq = true;
				}
			} 
			
		}
		
		return false;
	}

	@Override
	public int hashCode() {
		int hash = 7;
		if (property != null) hash*=property.hashCode();
		if (value != null) hash*=value.hashCode();
		
		//Ignore the transient Problem state
		
		return hash;
	}

	/**
	 * New instance
	 * 
	 * @param prop
	 * @param value 
	 */
	public PropertyValue(Property prop, T value) {
		this.property = prop;
		this.value = value;
	}

	public Property getProperty() {
		return property;
	}

	public T getValue() {
		return value;
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy