org.jtheque.core.managers.properties
Class PropertiesManager

java.lang.Object
  extended by org.jtheque.core.managers.AbstractManager
      extended by org.jtheque.core.managers.AbstractActivableManager
          extended by org.jtheque.core.managers.properties.PropertiesManager
All Implemented Interfaces:
ActivableManager, IManager, IPropertiesManager

public final class PropertiesManager
extends AbstractActivableManager
implements IPropertiesManager

A properties manager implementation.

Author:
Baptiste Wicht

Constructor Summary
PropertiesManager()
           
 
Method Summary
 boolean areEquals(Object bean, Object other, String... properties)
          Test if two object are equals referring to a certain list of properties.
<T> T
createMemento(T bean)
          Create a memento for the bean.
 Object getProperty(Object bean, String property)
          Return the value of the property.
 Object getPropertyQuickly(Object bean, String property)
          Return the value of the property.
 void restoreMemento(Object bean, Object memento)
          Restore the state of the memento.
 String toString(Object bean)
          Generate a toString() String based on all the properties of the bean.
 
Methods inherited from class org.jtheque.core.managers.AbstractActivableManager
isEnabled, setEnabled
 
Methods inherited from class org.jtheque.core.managers.AbstractManager
close, getErrorManager, getListeners, getLogger, getManager, getMessage, getMessage, getStates, init, preInit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jtheque.core.managers.ActivableManager
isEnabled, setEnabled
 
Methods inherited from interface org.jtheque.core.managers.IManager
close, init, preInit
 

Constructor Detail

PropertiesManager

public PropertiesManager()
Method Detail

createMemento

public <T> T createMemento(T bean)
Description copied from interface: IPropertiesManager
Create a memento for the bean. A memento is a clone of all the properties of the bean.

Note : The properties of the Object class are not retrieved.

Specified by:
createMemento in interface IPropertiesManager
Type Parameters:
T - The class of the bean.
Parameters:
bean - The bean to create the memento from.
Returns:
The memento.

restoreMemento

public void restoreMemento(Object bean,
                           Object memento)
Description copied from interface: IPropertiesManager
Restore the state of the memento. It seems to copy all the properties values from the memento to the bean.

Note : The properties of the Object class are not retrieved.

Specified by:
restoreMemento in interface IPropertiesManager
Parameters:
bean - The bean.
memento - The memento.

areEquals

public boolean areEquals(Object bean,
                         Object other,
                         String... properties)
Description copied from interface: IPropertiesManager
Test if two object are equals referring to a certain list of properties.

Specified by:
areEquals in interface IPropertiesManager
Parameters:
bean - The first bean.
other - The other bean.
properties - The properties to use.
Returns:
true if the two objects are equals else false.

getProperty

public Object getProperty(Object bean,
                          String property)
Description copied from interface: IPropertiesManager
Return the value of the property. This method parse the entire class, but use a cache, so it's better to use it when we have to access a lot of times the same class.

Specified by:
getProperty in interface IPropertiesManager
Parameters:
bean - The bean to get the property value from.
property - The property.
Returns:
the value of the property.

getPropertyQuickly

public Object getPropertyQuickly(Object bean,
                                 String property)
Description copied from interface: IPropertiesManager
Return the value of the property. This method doesn't parse the entire class, so it's quicker than getProperty() but it doesn't use cache so if you've to use it many times, use getProperty().

Specified by:
getPropertyQuickly in interface IPropertiesManager
Parameters:
bean - The bean to get the property value from.
property - The property.
Returns:
the value of the property.

toString

public String toString(Object bean)
Description copied from interface: IPropertiesManager
Generate a toString() String based on all the properties of the bean.

Note : The properties of the Object class are not retrieved.

Specified by:
toString in interface IPropertiesManager
Parameters:
bean - The bean.
Returns:
A String representation of all the properties of the bean.


Copyright © 2010 JTheque. All Rights Reserved.