ModeShape Distribution 3.0.0.Beta4

org.modeshape.common.util
Class Reflection.Property

java.lang.Object
  extended by org.modeshape.common.util.Reflection.Property
All Implemented Interfaces:
Serializable, Comparable<Reflection.Property>
Enclosing class:
Reflection

public static class Reflection.Property
extends Object
implements Comparable<Reflection.Property>, Serializable

A representation of a property on a Java object.

See Also:
Serialized Form

Constructor Summary
Reflection.Property()
          Create a new object property that has no fields initialized.
Reflection.Property(String name, String label, String description, boolean readOnly)
          Create a new object property with the supplied parameters set.
Reflection.Property(String name, String label, String description, String category, boolean readOnly, Class<?> type, Object... allowedValues)
          Create a new object property with the supplied parameters set.
 
Method Summary
 int compareTo(Reflection.Property that)
          
 boolean equals(Object obj)
          
 Collection<?> getAllowedValues()
          Get the allowed values for this property.
 String getCategory()
          Get the name of the category in which this property belongs.
 String getDescription()
          Get the description for this property.
 String getLabel()
          Get the human-readable label for the property.
 String getName()
          Get the property name in camel case.
 Class<?> getType()
          Get the class to which the value must belong (excluding null values).
 int hashCode()
          
 boolean isArrayType()
          Determine if this is property's (the type is an array.
 boolean isBooleanType()
          Determine if this is a boolean property (the type is a Boolean or boolean).
 boolean isInferred()
          Return whether this property was inferred purely by reflection, or whether annotations were used for its definition.
 boolean isPrimitive()
          Determine if this is property's (the type is a primitive.
 boolean isReadOnly()
          Return whether this property is read-only.
 void setAllowedValues(Collection<?> allowedValues)
          Set the allowed values for this property.
 void setAllowedValues(Object... allowedValues)
          Set the allowed values for this property.
 void setCategory(String category)
          Set the name of the category in which this property belongs.
 void setDescription(String description)
          Set the description for this property.
 void setInferred(boolean inferred)
          Set whether this property was inferred purely by reflection.
 void setLabel(String label)
          Set the human-readable label for the property.
 void setName(String name)
          Set the property name in camel case.
 void setReadOnly(boolean readOnly)
          Set whether this property is read-only.
 void setType(Class<?> type)
          Set the class to which the value must belong (excluding null values).
 String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Reflection.Property

public Reflection.Property()
Create a new object property that has no fields initialized.


Reflection.Property

public Reflection.Property(String name,
                           String label,
                           String description,
                           boolean readOnly)
Create a new object property with the supplied parameters set.

Parameters:
name - the property name; may be null
label - the human-readable property label; may be null
description - the description for this property; may be null
readOnly - true if the property is read-only, or false otherwise

Reflection.Property

public Reflection.Property(String name,
                           String label,
                           String description,
                           String category,
                           boolean readOnly,
                           Class<?> type,
                           Object... allowedValues)
Create a new object property with the supplied parameters set.

Parameters:
name - the property name; may be null
label - the human-readable property label; may be null
description - the description for this property; may be null
category - the category for this property; may be null
readOnly - true if the property is read-only, or false otherwise
type - the value class; may be null
allowedValues - the array of allowed values, or null or empty if the values are not constrained
Method Detail

getName

public String getName()
Get the property name in camel case. The getter method is simply "get" followed by the name of the property (with the first character of the property converted to uppercase). The setter method is "set" (or "is" for boolean properties) followed by the name of the property (with the first character of the property converted to uppercase).

Returns:
the property name; never null, but possibly empty

setName

public void setName(String name)
Set the property name in camel case. The getter method is simply "get" followed by the name of the property (with the first character of the property converted to uppercase). The setter method is "set" (or "is" for boolean properties) followed by the name of the property (with the first character of the property converted to uppercase).

Parameters:
name - the nwe property name; may be null

getLabel

public String getLabel()
Get the human-readable label for the property. This is often just a humanized form of the property name.

Returns:
label the human-readable property label; never null, but possibly empty

setLabel

public void setLabel(String label)
Set the human-readable label for the property. If null, this will be set to the humanized form of the property name.

Parameters:
label - the new label for the property; may be null

getDescription

public String getDescription()
Get the description for this property.

Returns:
the description; never null, but possibly empty

setDescription

public void setDescription(String description)
Set the description for this property.

Parameters:
description - the new description for this property; may be null

isReadOnly

public boolean isReadOnly()
Return whether this property is read-only.

Returns:
true if the property is read-only, or false otherwise

setReadOnly

public void setReadOnly(boolean readOnly)
Set whether this property is read-only.

Parameters:
readOnly - true if the property is read-only, or false otherwise

getCategory

public String getCategory()
Get the name of the category in which this property belongs.

Returns:
the category name; never null, but possibly empty

setCategory

public void setCategory(String category)
Set the name of the category in which this property belongs.

Parameters:
category - the category name; may be null

getType

public Class<?> getType()
Get the class to which the value must belong (excluding null values).

Returns:
the value class; never null, but may be Object.class

setType

public void setType(Class<?> type)
Set the class to which the value must belong (excluding null values).

Parameters:
type - the value class; may be null

isBooleanType

public boolean isBooleanType()
Determine if this is a boolean property (the type is a Boolean or boolean).

Returns:
true if this is a boolean property, or false otherwise

isPrimitive

public boolean isPrimitive()
Determine if this is property's (the type is a primitive.

Returns:
true if this property's type is a primitive, or false otherwise

isArrayType

public boolean isArrayType()
Determine if this is property's (the type is an array.

Returns:
true if this property's type is an array, or false otherwise

getAllowedValues

public Collection<?> getAllowedValues()
Get the allowed values for this property. If this is non-null and non-empty, the value must be one of these values.

Returns:
collection of allowed values, or the empty set if the values are not constrained

setAllowedValues

public void setAllowedValues(Collection<?> allowedValues)
Set the allowed values for this property. If this is non-null and non-empty, the value is expected to be one of these values.

Parameters:
allowedValues - the collection of allowed values, or null or empty if the values are not constrained

setAllowedValues

public void setAllowedValues(Object... allowedValues)
Set the allowed values for this property. If this is non-null and non-empty, the value is expected to be one of these values.

Parameters:
allowedValues - the array of allowed values, or null or empty if the values are not constrained

isInferred

public boolean isInferred()
Return whether this property was inferred purely by reflection, or whether annotations were used for its definition.

Returns:
true if it was inferred only by reflection, or false if at least one annotation was found and used

setInferred

public void setInferred(boolean inferred)
Set whether this property was inferred purely by reflection.

Parameters:
inferred - true if it was inferred only by reflection, or false if at least one annotation was found and used

compareTo

public int compareTo(Reflection.Property that)

Specified by:
compareTo in interface Comparable<Reflection.Property>
See Also:
Comparable.compareTo(java.lang.Object)

hashCode

public int hashCode()

Overrides:
hashCode in class Object
See Also:
Object.hashCode()

equals

public boolean equals(Object obj)

Overrides:
equals in class Object
See Also:
Object.equals(java.lang.Object)

toString

public String toString()

Overrides:
toString in class Object
See Also:
Object.toString()

ModeShape Distribution 3.0.0.Beta4

Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.