/** * Adds the attribute. * * @param type the type * @param value the value */ public void addAttribute(HwEntityAttributeType type, String value) { OnmsHwEntityAttribute attr = new OnmsHwEntityAttribute(type, value); attr.setHwEntity(this); m_hwAttributes.add(attr); }
@Override public int compareTo(OnmsHwEntityAttribute o) { return getTypeName().compareTo(o.getTypeName()); }
@Override public int hashCode() { return toString().hashCode(); }
/** * Gets the attribute value. * * @param typeName the type name * @return the attribute value */ public String getAttributeValue(String typeName) { final OnmsHwEntityAttribute attr = getAttribute(typeName); return attr == null ? null : attr.getValue(); }
/** * Gets the attribute class. * * @param typeName the type name * @return the attribute class */ public String getAttributeClass(String typeName) { final OnmsHwEntityAttribute attr = getAttribute(typeName); return attr == null ? null : attr.getType().getAttributeClass(); }
/** * Fix relationships. * * When a node is created from a XML, the internal relationships may not be correct. * Prior storing an hardware object into the database, this method must be called to * ensure that the DB relationships are correct. */ public void fixRelationships() { for (OnmsHwEntityAttribute attrib : m_hwAttributes) { attrib.setHwEntity(this); } if (m_children == null) return; for (OnmsHwEntity child : m_children) { child.setParent(this); child.fixRelationships(); } } }
@Override public boolean equals(Object obj) { if (obj == null) return false; if (obj instanceof OnmsHwEntityAttribute) { return toString().equals(obj.toString()); } return false; }
/** * Gets the attribute. * * @param typeName the type name * @return the attribute */ public OnmsHwEntityAttribute getAttribute(String typeName) { for (OnmsHwEntityAttribute attr : m_hwAttributes) { if (attr.getTypeName().equals(typeName)) { return attr; } } return null; }