org.joda.beans.impl.direct
Class DirectBean

java.lang.Object
  extended by org.joda.beans.impl.direct.DirectBean
All Implemented Interfaces:
Bean

public abstract class DirectBean
extends Object
implements Bean

A bean implementation designed for use by the code generator.

This implementation uses direct access via propertyGet(String, boolean) and propertySet(String, Object, boolean) to avoid reflection.

For code generation, the bean must directly extend this class and have a no-arguments constructor.


Constructor Summary
DirectBean()
           
 
Method Summary
 boolean equals(Object obj)
           
 int hashCode()
           
<R> Property<R>
property(String propertyName)
          Gets a property by name.
protected  Object propertyGet(String propertyName, boolean quiet)
          Gets the value of the property.
 Set<String> propertyNames()
          Gets the set of property names.
protected  void propertySet(String propertyName, Object value, boolean quiet)
          Sets the value of the property.
 String toString()
           
protected  void validate()
          Validates the values of the properties.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.joda.beans.Bean
metaBean
 

Constructor Detail

DirectBean

public DirectBean()
Method Detail

property

public <R> Property<R> property(String propertyName)
Description copied from interface: Bean
Gets a property by name.

Specified by:
property in interface Bean
Type Parameters:
R - the property type, optional, enabling auto-casting
Parameters:
propertyName - the property name to retrieve, null throws NoSuchElementException
Returns:
the property, not null

propertyNames

public Set<String> propertyNames()
Description copied from interface: Bean
Gets the set of property names.

Specified by:
propertyNames in interface Bean
Returns:
the unmodifiable map of property objects, not null

propertyGet

protected Object propertyGet(String propertyName,
                             boolean quiet)
Gets the value of the property.

Parameters:
propertyName - the property name, not null
quiet - true to return null if unable to read
Returns:
the value of the property, may be null
Throws:
NoSuchElementException - if the property name is invalid

propertySet

protected void propertySet(String propertyName,
                           Object value,
                           boolean quiet)
Sets the value of the property.

Parameters:
propertyName - the property name, not null
value - the value of the property, may be null
quiet - true to take no action if unable to write
Throws:
NoSuchElementException - if the property name is invalid

validate

protected void validate()
Validates the values of the properties.

Throws:
RuntimeException - if a property is invalid

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2007–2013 Joda.org. All rights reserved.