/** * Returns the unitsID of this object. * * @return the unitsID of this object. * @deprecated This is a requirement for Level 1 Version 1 and Version 2, * but can only be used in conjunction with {@link Parameter}s. * In this case this {@link AssignmentRule} represents the SBML * element ParameterRule. */ @Override @Deprecated public String getUnits() { return isSetUnits() ? unitsID : ""; }
@Override public int hashCode() { final int prime = 919; int hashCode = super.hashCode(); if (isSetVariable()) { hashCode += prime * getVariable().hashCode(); } if (isSetUnits()) { hashCode += prime * getUnits().hashCode(); } return hashCode; }
@Override public boolean equals(Object object) { boolean equals = super.equals(object); if (equals) { ExplicitRule r = (ExplicitRule) object; equals &= isSetVariable() == r.isSetVariable(); if (equals && isSetVariable()) { equals &= getVariable().equals(r.getVariable()); } equals &= isSetUnits() == r.isSetUnits(); if (equals && isSetUnits()) { equals &= getUnits().equals(r.getUnits()); } } return equals; }
/** * Creates a new {@link ExplicitRule} * * @param rule */ public ExplicitRule(ExplicitRule rule) { super(rule); initDefaults(); if (rule.isSetVariable()) { setVariable(new String(rule.getVariable())); } if (rule.isSetUnits()) { setUnits(new String(rule.getUnits())); } }
@Override public void setVariable(Variable variable) { if (variable != null) { if (variable.isConstant()) { throw new IllegalArgumentException(MessageFormat.format( resourceBundle.getString("Assignment.ILLEGAL_CONSTANT_VARIABLE_MSG"), variable.getId(), getElementName())); } if (isSetUnits() && !(variable instanceof Parameter)) { throw new IllegalArgumentException(MessageFormat.format( "Variable expected to be an instance of Parameter because a Unit attribute is set already, but given is an instance of {0}.", variable.getElementName())); } if ((getLevel() < 3) && (variable instanceof SpeciesReference)) { throw new IllegalArgumentException(MessageFormat.format( resourceBundle.getString("Assignment.ILLEGAL_VARIABLE_EXCEPTION_MSG"), variable.getId(), getElementName())); } if (variable.isSetId()) { String oldVariable = variableID; variableID = variable.getId(); firePropertyChange(TreeNodeChangeEvent.variable, oldVariable, variableID); } else { unsetVariable(); } } else { unsetVariable(); } }
attributes.put("name", getVariable()); if (isSetUnits()) { attributes.put(TreeNodeChangeEvent.units, getUnits());