lojix/power_model/src/main/com/thesett/aima/attribute/impl/EnumeratedStringAttribute.java
public void setId(long id)
    {
        // Find the enumeration node for this enumeration value.
        EnumerationNode node = null;

        // Check if the attribute class has been finalized yet.
        if (attributeClass.finalized)
        {
            // Fetch the string value from the attribute class array of finalized values.
            node = attributeClass.lookupValue[value];
        }
        else
        {
            // The attribute class has not been finalized yet.
            // Fetch the string value from the attribute class list of unfinalized values.
            node = attributeClass.lookupValueList.get(value);
        }

        // Extract the id from it.
        long existingId = node.id;

        // Do nothing if the new id matches the existing one.
        if (id == existingId)
        {
            return;
        }

        // Check if the type is finalized.
        if (attributeClass.finalized)
        {
            // Raise an illegal argument exception if the id is not known.
            EnumeratedStringAttribute newValue = attributeClass.getAttributeFromId(id);

            // Otherwise, change the value of this attribute to that of the new id.
            this.value = newValue.value;
        }
        else
        {
            // The type is un-finalized.
            // Check if another instance of the type already has the id and raise an exception if so.
            EnumerationNode existingNode = attributeClass.idMap.get(id);

            if (existingNode != null)
            {
                throw new IllegalArgumentException("The id value, " + id +
                    ", cannot be set because another instance of this type with that " + "id already exists.");
            }

            // Assign it to this instance if the type is unfinalized. Also removing the old id mapping from the id
            // map and replacing it with the new one.
            node.id = id;
            attributeClass.idMap.remove(existingId);
            attributeClass.idMap.put(id, node);
        }
    }
public void setId(long id)
    {
        // Find the enumeration node for this enumeration value.
        EnumerationNode node = null;

        // Check if the attribute class has been finalized yet.
        if (attributeClass.finalized)
        {
            // Fetch the string value from the attribute class array of finalized values.
            node = attributeClass.lookupValue[value];
        }
        else
        {
            // The attribute class has not been finalized yet.
            // Fetch the string value from the attribute class list of unfinalized values.
            node = attributeClass.lookupValueList.get(value);
        }

        // Extract the id from it.
        long existingId = node.id;

        // Do nothing if the new id matches the existing one.
        if (id == existingId)
        {
            return;
        }

        // Check if the type is finalized.
        if (attributeClass.finalized)
        {
            // Raise an illegal argument exception if the id is not known.
            EnumeratedStringAttribute newValue = attributeClass.getAttributeFromId(id);

            // Otherwise, change the value of this attribute to that of the new id.
            this.value = newValue.value;
        }
        else
        {
            // The type is un-finalized.
            // Check if another instance of the type already has the id and raise an exception if so.
            EnumerationNode existingNode = attributeClass.idMap.get(id);

            if (existingNode != null)
            {
                throw new IllegalArgumentException("The id value, " + id +
                    ", cannot be set because another instance of this type with that " + "id already exists.");
            }

            // Assign it to this instance if the type is unfinalized. Also removing the old id mapping from the id
            // map and replacing it with the new one.
            node.id = id;
            attributeClass.idMap.remove(existingId);
            attributeClass.idMap.put(id, node);
        }
    }
public void setId ( long id ) { // Find the enumeration node for this enumeration value. EnumerationNode node = null ; // Check if the attribute class has been finalized yet. if ( attributeClass . finalized ) { // Fetch the string value from the attribute class array of finalized values. node = attributeClass . lookupValue [ value ] ; } else { // The attribute class has not been finalized yet. // Fetch the string value from the attribute class list of unfinalized values. node = attributeClass . lookupValueList . get ( value ) ; } // Extract the id from it. long existingId = node . id ; // Do nothing if the new id matches the existing one. if ( id == existingId ) { return ; } // Check if the type is finalized. if ( attributeClass . finalized ) { // Raise an illegal argument exception if the id is not known. EnumeratedStringAttribute newValue = attributeClass . getAttributeFromId ( id ) ; // Otherwise, change the value of this attribute to that of the new id. this . value = newValue . value ; } else { // The type is un-finalized. // Check if another instance of the type already has the id and raise an exception if so. EnumerationNode existingNode = attributeClass . idMap . get ( id ) ; if ( existingNode != null ) { throw new IllegalArgumentException ( "The id value, " + id + ", cannot be set because another instance of this type with that " + "id already exists." ) ; } // Assign it to this instance if the type is unfinalized. Also removing the old id mapping from the id // map and replacing it with the new one. node . id = id ; attributeClass . idMap . remove ( existingId ) ; attributeClass . idMap . put ( id , node ) ; } }
Sets the integer id of the attribute. If the attribute class is finalized this will change the value of this
attribute to that of the matched id, or raise an exception if no matching id exists. If the attribute class is
unfinalized this will change the id value of this attribute within the attribute class to the new id, provided
that the id has not already been assigned to another attribute value. If it has been assigned to another
attribute value then an exception is raised.

@param  id The new id value.

@throws IllegalArgumentException If the type is finalized but the id does not exist. Or if the type is
unfinalized if the id has already been assigned to another instance of the type.
Sets the integer id of the attribute . If the attribute class is finalized this will change the value of this attribute to that of the matched id or raise an exception if no matching id exists . If the attribute class is unfinalized this will change the id value of this attribute within the attribute class to the new id provided that the id has not already been assigned to another attribute value . If it has been assigned to another attribute value then an exception is raised .