org.ujoframework.implementation.field
Class FieldUjoExt<UJO extends FieldUjoExt>

java.lang.Object
  extended by org.ujoframework.extensions.AbstractUjo
      extended by org.ujoframework.extensions.AbstractUjoExt<UJO>
          extended by org.ujoframework.implementation.field.FieldUjoExt<UJO>
All Implemented Interfaces:
UjoCloneable, UjoExt<UJO>, UjoMiddle<UJO>, UjoTextable, Ujo

public abstract class FieldUjoExt<UJO extends FieldUjoExt>
extends AbstractUjoExt<UJO>

The abstract Ujo implementation use a direct access to its private object fiels. An performance is similar like a MapUjo implementation however the FieldUjo solution have got smaller memore consumption.

Sample of usage

 public class Person extends FieldUjoExt {
   
   private Long cash;
   private List<Person> childs;
   
   public static UjoProperty<Person,Long> CASH
     = newProperty("CASH", Long.class
     , new ValueAgent<Person,Long>() {
     public void writeValue(
         Person ujo, Long value) { 
            ujo.cash = value; 
         }
     public Long readValue (Person ujo) { 
         return ujo.cash;  
     }
   });    
   
   public static UjoPropertyList<Person,Person> CHILDS
     = newListProperty("CHILDS", Person.class
     , new ValueAgent<Person,List<Person>>() {
     public void writeValue(Person ujo, List<Person> value) {
         ujo.childs = value; 
     }
     public List<Person> readValue(Person ujo) {
         return ujo.childs; 
     }
   });
 }

Since:
ujo-tool
Author:
Pavel Ponec
See Also:
FieldProperty

Constructor Summary
FieldUjoExt()
           
 
Method Summary
protected static
<UJO extends Ujo,ITEM>
FieldPropertyList<UJO,ITEM>
newListProperty(java.lang.String name, java.lang.Class<ITEM> type, ValueAgent<UJO,java.util.List<ITEM>> agent)
          A ListProperty Factory for a FieldUjo object
protected static
<UJO extends Ujo,VALUE>
FieldProperty<UJO,VALUE>
newProperty(java.lang.String name, java.lang.Class<VALUE> type, ValueAgent<UJO,VALUE> agent)
          Returns a new instance of property where the default value is null.
protected static
<UJO extends Ujo,VALUE>
FieldProperty<UJO,VALUE>
newProperty(java.lang.String name, VALUE value, ValueAgent<UJO,VALUE> agent)
          A Property Factory
 java.lang.Object readValue(UjoProperty property)
          It is a common method for reading all object values, however there is strongly recomended to use a method FieldProperty.getValue(Ujo) to an external access for a better type safe.
 void writeValue(UjoProperty property, java.lang.Object value)
          It is a common method for writing all object values, however there is strongly recomended to use a method FieldProperty.setValue(Ujo,Object) to an external access for a better type safe.
 
Methods inherited from class org.ujoframework.extensions.AbstractUjoExt
add, clone, copyTo, copyTo, createPropertyList, equals, findProperty, get, get, get, get, getItemCount, getText, isDefault, list, remove, remove, set, set, set, set, setText
 
Methods inherited from class org.ujoframework.extensions.AbstractUjo
equals, init, init, readAuthorization, readProperties, readUjoManager, readValueString, toString, writeValueString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ujoframework.Ujo
readAuthorization, readProperties
 

Constructor Detail

FieldUjoExt

public FieldUjoExt()
Method Detail

writeValue

public void writeValue(UjoProperty property,
                       java.lang.Object value)
It is a common method for writing all object values, however there is strongly recomended to use a method FieldProperty.setValue(Ujo,Object) to an external access for a better type safe. The method have got a strategy place for an implementation of several listeners and validators.
NOTE: If property is an incorrect then method throws an IllegalArgumentException.

Parameters:
property - Property must be a direct type only!
See Also:
FieldProperty.setValue(Ujo,Object)

readValue

public java.lang.Object readValue(UjoProperty property)
It is a common method for reading all object values, however there is strongly recomended to use a method FieldProperty.getValue(Ujo) to an external access for a better type safe. The method have got a strategy place for an implementation of several listeners and convertors.
NOTE: If property is an incorrect then method throws an IllegalArgumentException.

Parameters:
property - Property must be a direct type only!
Returns:
Property value
See Also:
FieldProperty.getValue(Ujo)

newProperty

protected static <UJO extends Ujo,VALUE> FieldProperty<UJO,VALUE> newProperty(java.lang.String name,
                                                                              java.lang.Class<VALUE> type,
                                                                              ValueAgent<UJO,VALUE> agent)
Returns a new instance of property where the default value is null.


newProperty

protected static <UJO extends Ujo,VALUE> FieldProperty<UJO,VALUE> newProperty(java.lang.String name,
                                                                              VALUE value,
                                                                              ValueAgent<UJO,VALUE> agent)
A Property Factory


newListProperty

protected static <UJO extends Ujo,ITEM> FieldPropertyList<UJO,ITEM> newListProperty(java.lang.String name,
                                                                                    java.lang.Class<ITEM> type,
                                                                                    ValueAgent<UJO,java.util.List<ITEM>> agent)
A ListProperty Factory for a FieldUjo object



Copyright © 2010. All Rights Reserved.