Computed attributes based on the object state

The IlpDefaultClass IltObject business class includes a number of predefined attributes that make it possible to represent the state of the object in the table component. However, you might want to display other information that is contained in the object state in a table column. To do so, you can define a new computed attribute based on the object state.
The following example shows how to define a new computed attribute that returns the number of major new alarms.

How to define a new computed attribute

IlpAttribute NewMajorAlarmAttribute =
  new IltComputedAttribute("newMajorAlarmAttribute",
                           String.class) {
    public Object getValue (IlpAttributeValueHolder h) {
      IltObjectState oState =
         (IltObjectState)h.getAttributeValue(IltObject.ObjectStateAttribute);
      IltAlarm.State alarmState = oState == null
        ? null : (IltAlarm.State)oState.getAlarmState();
      if ( alarmState == null ) return null;
        return alarmState.getNewAlarmCount(IltAlarm.Severity.Major);
    }

    public boolean isDependentOn (IlpAttribute a) {
      return a.getName().equals(ObjectStateAttribute.getName());
    }
  };