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

com.ctreber.aclib.gui.MOEnum Maven / Gradle / Ivy

Go to download

PlantUML is a component that allows to quickly write : * sequence diagram, * use case diagram, * class diagram, * activity diagram, * component diagram, * state diagram * object diagram

The newest version!
package com.ctreber.aclib.gui;

import java.util.HashSet;

/**
 * 

* Monitored enumeration value. *

* *

* © 2002 Christian Treber, [email protected] *

* * @author Christian Treber, [email protected] * */ public class MOEnum extends MonitoredObject { private HashSet fValidValues = new HashSet(); /** *

* null if no value selected */ private Object fValue; public void addValidValue(Object pValue) { fValidValues.add(pValue); } public void set(Object pValue) { if (pValue != null) { checkValue(pValue); } fValue = pValue; fireValueChanged(); } public Object get() { return fValue; } public boolean is(Object pObject) { checkValue(pObject); return this.equals(pObject); } public int hashCode() { if (fValue == null) { return 0; } return fValue.hashCode(); } private void checkValue(Object pValue) { if (!fValidValues.contains(pValue)) { throw new IllegalArgumentException("Illegal enum value '" + pValue + "'"); } } public boolean equals(Object obj) { if (obj instanceof MOEnum) { MOEnum lOther = (MOEnum) obj; if (fValue == null) { return lOther.fValue == null; } return fValue.equals(lOther.fValue); } if (fValue == null) { return obj.equals(null); } return fValue.equals(obj); } public HashSet getValidValues() { return fValidValues; } public boolean checkRange() { return true; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy