| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public class ImmutableDescriptor extends Object implements Descriptor
An immutable descriptor.
Field Summary | |
---|---|
static ImmutableDescriptor |
EMPTY_DESCRIPTOR
An empty descriptor. |
Constructor Summary | |
---|---|
ImmutableDescriptor(Map fields) Construct a descriptor where the names and values of the fields are the keys and values of the given Map. |
|
ImmutableDescriptor(String[] fields) Construct a descriptor containing the given fields. |
|
ImmutableDescriptor(String[] fieldNames, Object[] fieldValues) Construct a descriptor containing the given fields and values. |
Method Summary | |
---|---|
Descriptor |
clone() Returns a descriptor which is equal to this descriptor. |
boolean |
Compares this descriptor to the given object. |
String[] |
|
String[] |
|
Object |
getFieldValue(String fieldName) |
Object[] |
getFieldValues(String[] fieldNames) |
int |
hashCode() Returns the hash code value for this descriptor. |
boolean |
isValid() Returns true if all of the fields have legal values given their names. |
void |
removeField(String fieldName) Removes a field from the descriptor. |
void |
This operation is unsupported since this class is immutable. |
void |
This operation is unsupported since this class is immutable. |
String |
toString() Returns a string representation of the object. |
static ImmutableDescriptor |
union(Descriptor[] descriptors) Return an whose contents are the union of the given descriptors. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final ImmutableDescriptor EMPTY_DESCRIPTOR
Constructor Detail |
---|
public ImmutableDescriptor(Map fields)
Construct a descriptor where the names and values of the fields are the keys and values of the given Map.
fields
public ImmutableDescriptor(String[] fields)
fields
public ImmutableDescriptor(String[] fieldNames, Object[] fieldValues)
fieldNames
fieldValues
Method Detail |
---|
public Descriptor clone()
Returns a descriptor which is equal to this descriptor. Changes to the returned descriptor will have no effect on this descriptor, and vice versa.
This method returns the object on which it is called. A subclass can override it to return another object provided the contract is respected.
clone
in class Object
public boolean equals(Object o)
equals
in class Object
o
- the object to compare with.public final String[] getFieldNames()
public final String[] getFields()
public final Object getFieldValue(String fieldName)
fieldName
public final Object[] getFieldValues(String[] fieldNames)
fieldNames
public int hashCode()
Returns the hash code value for this descriptor. The hash code is computed as the sum of the hash codes for each field in the descriptor. The hash code of a field with name {@code n} and value {@code v} is {@code n.toLowerCase().hashCode() ^ h}. Here {@code h} is the hash code of {@code v}, computed as follows:
hashCode
in class Object
public boolean isValid()
public final void removeField(String fieldName)
fieldName
- String name of the field to be removed.
If the field name is illegal or the field is not found,
no exception is thrown.public final void setField(String fieldName, Object fieldValue) throws RuntimeOperationsException
fieldName
fieldValue
RuntimeOperationsException
public final void setFields(String[] fieldNames, Object[] fieldValues) throws RuntimeOperationsException
fieldNames
fieldValues
RuntimeOperationsException
public String toString()
toString
in class Object
public static ImmutableDescriptor union(Descriptor[] descriptors)
Return an {@code ImmutableDescriptor} whose contents are the union of the given descriptors. Every field name that appears in any of the descriptors will appear in the result with the value that it has when the method is called. Subsequent changes to any of the descriptors do not affect the ImmutableDescriptor returned here.
In the simplest case, there is only one descriptor and the returned {@code ImmutableDescriptor} is a copy of its fields at the time this method is called:
Descriptor d = something(); ImmutableDescriptor copy = ImmutableDescriptor.union(d);
descriptors
- the descriptors to be combined. Any of the
descriptors can be null, in which case it is skipped.
| |||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |