Package cdc.util.data
Class Attribute
- java.lang.Object
-
- cdc.util.data.Attribute
-
public final class Attribute extends Object
XML like attribute ([name, value] pair).An attribute name can not be changed after creation. Its value can be modified.
- Author:
- Damien Carbonne
-
-
Field Summary
Fields Modifier and Type Field Description static Comparator<Attribute>NAME_COMPARATORA Comparator of attributes that compares names.
-
Constructor Summary
Constructors Constructor Description Attribute(Attribute other)Attribute(String name)Attribute(String name, boolean value)Attribute(String name, byte value)Attribute(String name, double value)Attribute(String name, float value)Attribute(String name, int value)Attribute(String name, long value)Attribute(String name, short value)Attribute(String name, E value)Attribute(String name, Object value)Attribute(String name, String value)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object object)StringgetName()StringgetValue()booleangetValueAsBoolean()bytegetValueAsByte()doublegetValueAsDouble()<E extends Enum<E>>
EgetValueAsEnum(Class<E> enumClass)floatgetValueAsFloat()intgetValueAsInt()longgetValueAsLong()shortgetValueAsShort()inthashCode()static Predicate<Attribute>named(String name)Creates a Predicate that accepts Attributes with a given name.static Predicate<Attribute>named(String... names)Creates a Predicate that accepts Attributes with a name belonging to an array.static Predicate<Attribute>named(Set<String> names)Creates a Predicate that accepts Attributes with a name belonging to a set.voidsetValue(boolean value)voidsetValue(byte value)voidsetValue(double value)voidsetValue(float value)voidsetValue(int value)voidsetValue(long value)voidsetValue(short value)<E extends Enum<E>>
voidsetValue(E value)voidsetValue(Object value)voidsetValue(String value)StringtoString()
-
-
-
Field Detail
-
NAME_COMPARATOR
public static final Comparator<Attribute> NAME_COMPARATOR
A Comparator of attributes that compares names.
-
-
Constructor Detail
-
Attribute
public Attribute(String name)
-
Attribute
public Attribute(Attribute other)
-
Attribute
public Attribute(String name, E value)
-
Attribute
public Attribute(String name, boolean value)
-
Attribute
public Attribute(String name, long value)
-
Attribute
public Attribute(String name, int value)
-
Attribute
public Attribute(String name, short value)
-
Attribute
public Attribute(String name, byte value)
-
Attribute
public Attribute(String name, double value)
-
Attribute
public Attribute(String name, float value)
-
-
Method Detail
-
setValue
public void setValue(Object value)
-
setValue
public void setValue(String value)
-
setValue
public void setValue(boolean value)
-
setValue
public void setValue(long value)
-
setValue
public void setValue(int value)
-
setValue
public void setValue(short value)
-
setValue
public void setValue(byte value)
-
setValue
public void setValue(double value)
-
setValue
public void setValue(float value)
-
setValue
public <E extends Enum<E>> void setValue(E value)
-
getName
public String getName()
-
getValue
public String getValue()
-
getValueAsBoolean
public boolean getValueAsBoolean()
-
getValueAsLong
public long getValueAsLong()
-
getValueAsInt
public int getValueAsInt()
-
getValueAsShort
public short getValueAsShort()
-
getValueAsByte
public byte getValueAsByte()
-
getValueAsDouble
public double getValueAsDouble()
-
getValueAsFloat
public float getValueAsFloat()
-
named
public static Predicate<Attribute> named(String name)
Creates a Predicate that accepts Attributes with a given name.- Parameters:
name- The name.- Returns:
- A new Predicate that accepts Attributes that are named
name.
-
named
public static Predicate<Attribute> named(Set<String> names)
Creates a Predicate that accepts Attributes with a name belonging to a set.- Parameters:
names- The names.- Returns:
- A new Predicate that accepts Attributes whose name belongs to
names.
-
-