org.ujoframework.extensions
Class PathProperty<UJO extends Ujo,VALUE>

java.lang.Object
  extended by org.ujoframework.extensions.PathProperty<UJO,VALUE>
All Implemented Interfaces:
java.lang.CharSequence, UjoProperty<UJO,VALUE>
Direct Known Subclasses:
SortingProperty

public class PathProperty<UJO extends Ujo,VALUE>
extends java.lang.Object
implements UjoProperty<UJO,VALUE>

A PathProperty class is an composite of a UjoProperty objects. The PathProperty class can be used wherever is used UjoProperty - with a one important exception: do not send the PathProperty object to methods Ujo.readValue(...) and Ujo.writeValue(...) !!!

You can use the preferred methods UjoManager.setValue(...) / UjoManager.getValue(...) to write and read a value instead of or use some type safe solution by UjoExt or a method of UjoProperty.

Note that method isDirect() returns a false in this class. For this reason, the property is not included in the list returned by Ujo.readProperties().

Since:
0.81
Author:
Pavel Ponec

Constructor Summary
PathProperty(java.util.List<UjoProperty> properties)
           
PathProperty(UjoProperty... properties)
           
 
Method Summary
<VALUE_PAR>
UjoProperty<UJO,VALUE_PAR>
add(UjoProperty<? extends VALUE,VALUE_PAR> property)
          Create new composite (indirect) instance.
 void copy(UJO from, UJO to)
          Copy a value from the first UJO object to second one.
static
<UJO extends Ujo,VALUE>
PathProperty<UJO,VALUE>
create(UjoProperty<UJO,? extends java.lang.Object>... properties)
          Create new instance
 UjoProperty<UJO,VALUE> descending()
          Create a new instance of the property with a descending direction of order.
 boolean equals(UJO ujo, VALUE value)
          Returns true, if the property value equals to a parameter value.
 void exportProperties(java.util.List<UjoProperty> result)
          Export all direct properties to the list from parameter.
 VALUE getDefault()
          Returns a default value
 int getIndex()
          Returns a property index or value -1 if the property index is not defined.
<UJO_IMPL extends Ujo>
UjoProperty<UJO_IMPL,VALUE>
getLastProperty()
          Get the last property of the current object.
 java.lang.String getName()
          Full property name
 UjoProperty getProperty(int index)
          Get a property from selected positon..
 int getPropertyCount()
          Returns a count of properties
 Ujo getSemifinalValue(UJO ujo)
          Get a semifinal value from an Ujo object by a chain of properties.
 java.lang.Class<VALUE> getType()
          Property type
 VALUE getValue(UJO ujo)
          Get a value from an Ujo object by a chain of properties.
 char charAt(int index)
          A char from Name
 boolean isAscending()
          A flag for an ascending direction of order.
 boolean isDefault(UJO ujo)
          Indicates whether a parameter value of the ujo "equal to" this default value.
 boolean isDirect()
          Method returns a false because this is a property of the another UJO class.
 boolean isTypeOf(java.lang.Class type)
          Returns true if the property type is a type or subtype of the parameter class.
 int length()
          Length of the Name
static
<UJO1 extends Ujo,UJO2 extends Ujo,UJO3 extends Ujo,UJO4 extends Ujo,VALUE>
PathProperty<UJO1,VALUE>
newInstance(UjoProperty<UJO1,UJO2> property1, UjoProperty<UJO2,UJO3> property2, UjoProperty<UJO3,UJO4> property3, UjoProperty<UJO4,VALUE> property4)
          Create new instance
static
<UJO1 extends Ujo,UJO2 extends Ujo,UJO3 extends Ujo,VALUE>
PathProperty<UJO1,VALUE>
newInstance(UjoProperty<UJO1,UJO2> property1, UjoProperty<UJO2,UJO3> property2, UjoProperty<UJO3,VALUE> property3)
          Create new instance
static
<UJO1 extends Ujo,UJO2 extends Ujo,VALUE>
PathProperty<UJO1,VALUE>
newInstance(UjoProperty<UJO1,UJO2> property1, UjoProperty<UJO2,VALUE> property2)
          Create new instance
static
<UJO extends Ujo,VALUE>
PathProperty<UJO,VALUE>
newInstance(UjoProperty<UJO,VALUE> property)
          Create new instance
 VALUE of(UJO ujo)
          A shortcut for the method getValue(Ujo) .
 void setValue(UJO ujo, VALUE value)
          It is a basic method for setting an appropriate type safe value to an Ujo object.
 java.lang.CharSequence subSequence(int start, int end)
          Sub sequence from the Name
 java.lang.String toString()
          Returns the name of Property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PathProperty

public PathProperty(java.util.List<UjoProperty> properties)

PathProperty

public PathProperty(UjoProperty... properties)
Method Detail

getLastProperty

public final <UJO_IMPL extends Ujo> UjoProperty<UJO_IMPL,VALUE> getLastProperty()
Get the last property of the current object. The result may not be the direct property.


getProperty

public final UjoProperty getProperty(int index)
Get a property from selected positon.. The result may not be the direct property.


getPropertyCount

public final int getPropertyCount()
Returns a count of properties


getName

public java.lang.String getName()
Full property name

Specified by:
getName in interface UjoProperty<UJO extends Ujo,VALUE>

getType

public java.lang.Class<VALUE> getType()
Property type

Specified by:
getType in interface UjoProperty<UJO extends Ujo,VALUE>

getSemifinalValue

public Ujo getSemifinalValue(UJO ujo)
Get a semifinal value from an Ujo object by a chain of properties. If any value (not getLastProperty) is null, then the result is null.


getValue

public VALUE getValue(UJO ujo)
Get a value from an Ujo object by a chain of properties. If a value (not getLastProperty) is null, then the result is null.

Specified by:
getValue in interface UjoProperty<UJO extends Ujo,VALUE>
Parameters:
ujo - If a NULL parameter is used then an exception NullPointerException is throwed.
Returns:
Returns a type safe value from the ujo object.
See Also:
Ujo.readValue(UjoProperty)

setValue

public void setValue(UJO ujo,
                     VALUE value)
Description copied from interface: UjoProperty
It is a basic method for setting an appropriate type safe value to an Ujo object.
The method calls a method Ujo.writeValue(org.ujoframework.UjoProperty, java.lang.Object) always.

Specified by:
setValue in interface UjoProperty<UJO extends Ujo,VALUE>
See Also:
Ujo.writeValue(org.ujoframework.UjoProperty, java.lang.Object)

getIndex

public final int getIndex()
Description copied from interface: UjoProperty
Returns a property index or value -1 if the property index is not defined.
The index is reasonable for an implementation an ArrayUjo class and the value is used is used
for a sorting of Properties in a method UjoManager.readProperties(Class type) .

Specified by:
getIndex in interface UjoProperty<UJO extends Ujo,VALUE>
See Also:
ArrayUjo, UjoManager.readProperties(Class)

getDefault

public VALUE getDefault()
Returns a default value

Specified by:
getDefault in interface UjoProperty<UJO extends Ujo,VALUE>
See Also:
Ujo.readValue(UjoProperty)

isDefault

public boolean isDefault(UJO ujo)
Indicates whether a parameter value of the ujo "equal to" this default value.

Specified by:
isDefault in interface UjoProperty<UJO extends Ujo,VALUE>

copy

public void copy(UJO from,
                 UJO to)
Copy a value from the first UJO object to second one. A null value is not replaced by the default.

Specified by:
copy in interface UjoProperty<UJO extends Ujo,VALUE>

isTypeOf

public boolean isTypeOf(java.lang.Class type)
Returns true if the property type is a type or subtype of the parameter class.

Specified by:
isTypeOf in interface UjoProperty<UJO extends Ujo,VALUE>

equals

public boolean equals(UJO ujo,
                      VALUE value)
Returns true, if the property value equals to a parameter value. The property value can be null.

Specified by:
equals in interface UjoProperty<UJO extends Ujo,VALUE>
Parameters:
ujo - A basic Ujo.
value - Null value is supported.
Returns:
Accordance

of

public final VALUE of(UJO ujo)
A shortcut for the method getValue(Ujo) .

Specified by:
of in interface UjoProperty<UJO extends Ujo,VALUE>
See Also:
getValue(Ujo)

toString

public java.lang.String toString()
Description copied from interface: UjoProperty
Returns the name of Property.

Specified by:
toString in interface java.lang.CharSequence
Specified by:
toString in interface UjoProperty<UJO extends Ujo,VALUE>
Overrides:
toString in class java.lang.Object

length

public int length()
Length of the Name

Specified by:
length in interface java.lang.CharSequence

charAt

public char charAt(int index)
A char from Name

Specified by:
charAt in interface java.lang.CharSequence

subSequence

public java.lang.CharSequence subSequence(int start,
                                          int end)
Sub sequence from the Name

Specified by:
subSequence in interface java.lang.CharSequence

isDirect

public final boolean isDirect()
Method returns a false because this is a property of the another UJO class. The composite property is excluded from from function Ujo.readProperties() by default.

Specified by:
isDirect in interface UjoProperty<UJO extends Ujo,VALUE>

isAscending

public boolean isAscending()
A flag for an ascending direction of order. For the result is significant only the last property.

Specified by:
isAscending in interface UjoProperty<UJO extends Ujo,VALUE>
See Also:
UjoComparator

descending

public UjoProperty<UJO,VALUE> descending()
Create a new instance of the property with a descending direction of order.

Specified by:
descending in interface UjoProperty<UJO extends Ujo,VALUE>
Returns:
returns a new instance of the indirect UjoProperty
See Also:
UjoComparator

exportProperties

public void exportProperties(java.util.List<UjoProperty> result)
Export all direct properties to the list from parameter.


add

public <VALUE_PAR> UjoProperty<UJO,VALUE_PAR> add(UjoProperty<? extends VALUE,VALUE_PAR> property)
Create new composite (indirect) instance.

Specified by:
add in interface UjoProperty<UJO extends Ujo,VALUE>
Since:
0.92

newInstance

public static final <UJO extends Ujo,VALUE> PathProperty<UJO,VALUE> newInstance(UjoProperty<UJO,VALUE> property)
Create new instance


newInstance

public static final <UJO1 extends Ujo,UJO2 extends Ujo,VALUE> PathProperty<UJO1,VALUE> newInstance(UjoProperty<UJO1,UJO2> property1,
                                                                                                   UjoProperty<UJO2,VALUE> property2)
Create new instance


newInstance

public static final <UJO1 extends Ujo,UJO2 extends Ujo,UJO3 extends Ujo,VALUE> PathProperty<UJO1,VALUE> newInstance(UjoProperty<UJO1,UJO2> property1,
                                                                                                                    UjoProperty<UJO2,UJO3> property2,
                                                                                                                    UjoProperty<UJO3,VALUE> property3)
Create new instance


newInstance

public static final <UJO1 extends Ujo,UJO2 extends Ujo,UJO3 extends Ujo,UJO4 extends Ujo,VALUE> PathProperty<UJO1,VALUE> newInstance(UjoProperty<UJO1,UJO2> property1,
                                                                                                                                     UjoProperty<UJO2,UJO3> property2,
                                                                                                                                     UjoProperty<UJO3,UJO4> property3,
                                                                                                                                     UjoProperty<UJO4,VALUE> property4)
Create new instance


create

public static final <UJO extends Ujo,VALUE> PathProperty<UJO,VALUE> create(UjoProperty<UJO,? extends java.lang.Object>... properties)
Create new instance



Copyright © 2010. All Rights Reserved.