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

java.lang.Object
  extended by org.ujorm.extensions.PathProperty<UJO,VALUE>
All Implemented Interfaces:
java.lang.CharSequence, java.lang.Comparable<UjoProperty>, CompositeProperty<UJO,VALUE>, CriterionProvider<UJO,VALUE>, UjoProperty<UJO,VALUE>

public final class PathProperty<UJO extends Ujo,VALUE>
extends java.lang.Object
implements CompositeProperty<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(...) !!!

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.lang.Boolean ascending, UjoProperty... properties)
          Main constructor
PathProperty(java.util.List<UjoProperty> properties)
           
PathProperty(UjoProperty... properties)
          The main constructor.
 
Method Summary
<VALUE_PAR>
CompositeProperty<UJO,VALUE_PAR>
add(UjoProperty<? extends VALUE,VALUE_PAR> property)
          Create new composite (indirect) instance.
 int compareTo(UjoProperty p)
          Compare to another UjoProperty object by the index and name of the property.
 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.
 UjoProperty<UJO,VALUE> descending(boolean descending)
          Create a new instance of the property with a descending direction of order.
 boolean equals(java.lang.Object property)
          Returns true, if the property value equals to a parameter value.
 boolean equals(UJO ujo, VALUE value)
          Returns true, if the property value equals to a parameter value.
 boolean equalsName(java.lang.CharSequence name)
          Returns true, if the property name equals to the parameter value.
 void exportProperties(java.util.List<UjoProperty> result)
          Export all direct properties to the list from parameter.
 Criterion<UJO> forAll()
          Create a new Criterion for this property where all results will be true (the result is independed on the value).
 Criterion<UJO> forNone()
          Create a new Criterion for this property where all results will be false (the result is independed on the value).
 Criterion<UJO> forSql(java.lang.String sqlCondition)
          Create a new Criterion for a Native Criterion in SQL statement format.
 VALUE getDefault()
          Returns a default value
<UJO_IMPL extends Ujo>
UjoProperty<UJO_IMPL,VALUE>
getFirstProperty()
          Get the first property of the current object.
 int getIndex()
          Returns a property index or value -1 if the property index is not defined.
<UJO_IMPL extends Ujo>
UjoProperty<UJO_IMPL,VALUE>
getLastPartialProperty()
          Get the last property of the current object.
<UJO_IMPL extends Ujo>
UjoProperty<UJO_IMPL,VALUE>
getLastProperty()
          Get the first property of the current object.
 java.lang.String getName()
          Full property name
 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.
 int hashCode()
           
 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)
          Quick instance for the direct properrites
static
<UJO extends Ujo,VALUE>
PathProperty<UJO,VALUE>
newInstance(UjoProperty<UJO,VALUE> property)
          Quick instance for the direct property.
static
<UJO extends Ujo,VALUE>
PathProperty<UJO,VALUE>
newInstance(UjoProperty<UJO,VALUE> property, boolean ascending)
          Create a new instance of property with a new sort attribute value.
 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.
static
<UJO extends Ujo,VALUE>
PathProperty<UJO,VALUE>
sort(UjoProperty<UJO,VALUE> property, boolean ascending)
          Create a new instance of property with a new sort attribute value.
 java.lang.CharSequence subSequence(int start, int end)
          Sub sequence from the Name
 java.lang.String toString()
          Returns the name of Property.
 Criterion<UJO> where(Operator operator, UjoProperty<?,VALUE> value)
          Create a new Criterion where this property is related to the value along the parameter Operator.
 Criterion<UJO> where(Operator operator, VALUE value)
          Create a new Criterion where this property is related to the value along the parameter Operator.
 Criterion<UJO> whereEq(UjoProperty<UJO,VALUE> value)
          Create a new Criterion where this property equals the property
 Criterion<UJO> whereEq(VALUE value)
          Create a new Criterion where this property equals the value
 Criterion<UJO> whereGe(VALUE value)
          Create a new Criterion where this property is great or equals the value
 Criterion<UJO> whereGt(VALUE value)
          Create a new Criterion where this property is great then the value
 Criterion<UJO> whereIn(java.util.Collection<VALUE> list)
          Create new Criterion for operator IN to compare value to a list of constants.
 Criterion<UJO> whereIn(VALUE... list)
          Create new Criterion for operator IN to compare value to a list of constants
 Criterion<UJO> whereLe(VALUE value)
          Create a new Criterion where this property is less or equals than the value
 Criterion<UJO> whereLt(VALUE value)
          Create a new Criterion where this property is less then the value
 Criterion<UJO> whereNeq(VALUE value)
          Create a new Criterion where this property not equals the value
 Criterion<UJO> whereNotIn(java.util.Collection<VALUE> list)
          Create new Criterion for operator IN to compare value to a list of constants.
 Criterion<UJO> whereNotIn(VALUE... list)
          Create new Criterion for operator IN to compare value to a list of constants.
 Criterion<UJO> whereNotNull()
          Create a new Criterion where this property is not null.
 Criterion<UJO> whereNull()
          Create a new Criterion where this property is null.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PathProperty

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

PathProperty

public PathProperty(UjoProperty... properties)
The main constructor. It is recommended to use the factory method newInstance(..) for better performance in some cases.

See Also:
newInstance(..)

PathProperty

public PathProperty(java.lang.Boolean ascending,
                    UjoProperty... properties)
Main constructor

Method Detail

getLastPartialProperty

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


getLastProperty

public final <UJO_IMPL extends Ujo> UjoProperty<UJO_IMPL,VALUE> getLastProperty()
Get the first property of the current object. The result is direct property always.

Specified by:
getLastProperty in interface CompositeProperty<UJO extends Ujo,VALUE>

getFirstProperty

public final <UJO_IMPL extends Ujo> UjoProperty<UJO_IMPL,VALUE> getFirstProperty()
Get the first property of the current object. The result is direct property always.

Specified by:
getFirstProperty in interface CompositeProperty<UJO extends Ujo,VALUE>

getName

public final 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 getLastPartialProperty) is null, then the result is null.

Specified by:
getSemifinalValue in interface CompositeProperty<UJO extends Ujo,VALUE>

getValue

public VALUE getValue(UJO ujo)
Get a value from an Ujo object by a chain of properties. If a value (not getLastPartialProperty) 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.ujorm.UjoProperty, java.lang.Object) always.

Specified by:
setValue in interface UjoProperty<UJO extends Ujo,VALUE>
See Also:
Ujo.writeValue(org.ujorm.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

equalsName

public boolean equalsName(java.lang.CharSequence name)
Returns true, if the property name equals to the parameter value.

Specified by:
equalsName in interface UjoProperty<UJO extends Ujo,VALUE>
Parameters:
name - The name of a property

equals

public boolean equals(java.lang.Object property)
Returns true, if the property value equals to a parameter value. The property value can be null.

Overrides:
equals in class java.lang.Object
Parameters:
property - A basic CujoProperty.
value - Null value is supported.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

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>
See Also:
CompositeProperty

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

descending

public UjoProperty<UJO,VALUE> descending(boolean 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.

Specified by:
exportProperties in interface CompositeProperty<UJO extends Ujo,VALUE>

add

public <VALUE_PAR> CompositeProperty<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

compareTo

public int compareTo(UjoProperty p)
Compare to another UjoProperty object by the index and name of the property.

Specified by:
compareTo in interface java.lang.Comparable<UjoProperty>
Specified by:
compareTo in interface UjoProperty<UJO extends Ujo,VALUE>
Since:
1.20

sort

public static <UJO extends Ujo,VALUE> PathProperty<UJO,VALUE> sort(UjoProperty<UJO,VALUE> property,
                                                                   boolean ascending)
Create a new instance of property with a new sort attribute value.


newInstance

public static <UJO extends Ujo,VALUE> PathProperty<UJO,VALUE> newInstance(UjoProperty<UJO,VALUE> property,
                                                                          boolean ascending)
Create a new instance of property with a new sort attribute value. This is an alias for the static method sort().

See Also:
sort(..)

newInstance

public static <UJO extends Ujo,VALUE> PathProperty<UJO,VALUE> newInstance(UjoProperty<UJO,VALUE> property)
Quick instance for the direct property.


newInstance

public static <UJO1 extends Ujo,UJO2 extends Ujo,VALUE> PathProperty<UJO1,VALUE> newInstance(UjoProperty<UJO1,UJO2> property1,
                                                                                             UjoProperty<UJO2,VALUE> property2)
Quick instance for the direct properrites


newInstance

public 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


newInstance

public 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


create

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


where

public Criterion<UJO> where(Operator operator,
                            VALUE value)
Create a new Criterion where this property is related to the value along the parameter Operator.

Specified by:
where in interface CriterionProvider<UJO extends Ujo,VALUE>
Parameters:
operator - Operator
  • VALUE - the parameter value
  • UjoProperty - reference to a related entity
  • List<TYPE> - list of values (TODO - this type is planned in the future)
Returns:
A new criterion

where

public Criterion<UJO> where(Operator operator,
                            UjoProperty<?,VALUE> value)
Create a new Criterion where this property is related to the value along the parameter Operator.

Specified by:
where in interface CriterionProvider<UJO extends Ujo,VALUE>
Parameters:
operator - Operator
  • VALUE - the parameter value
  • UjoProperty - reference to a related entity
  • List<TYPE> - list of values (TODO - this type is planned in the future)
Returns:
A new criterion

whereEq

public Criterion<UJO> whereEq(VALUE value)
Create a new Criterion where this property equals the value

Specified by:
whereEq in interface CriterionProvider<UJO extends Ujo,VALUE>
Returns:
A the new immutable Criterion

whereEq

public Criterion<UJO> whereEq(UjoProperty<UJO,VALUE> value)
Create a new Criterion where this property equals the property

Specified by:
whereEq in interface CriterionProvider<UJO extends Ujo,VALUE>
Parameters:
value - UjoProperty can be type a direct of indirect (for a relation) property
Returns:
A the new immutable Criterion

whereIn

public Criterion<UJO> whereIn(java.util.Collection<VALUE> list)
Create new Criterion for operator IN to compare value to a list of constants.

Specified by:
whereIn in interface CriterionProvider<UJO extends Ujo,VALUE>
Parameters:
list - A collection of the values. The collection argument can be the EMPTY, the Criterion result will be FALSE in this case.
Returns:
A the new immutable Criterion.

whereNotIn

public Criterion<UJO> whereNotIn(java.util.Collection<VALUE> list)
Create new Criterion for operator IN to compare value to a list of constants.

Specified by:
whereNotIn in interface CriterionProvider<UJO extends Ujo,VALUE>
Parameters:
list - A collection of the values. The collection argument can be the EMPTY, the Criterion result will be TRUE in this case.
Returns:
A the new immutable Criterion.

whereIn

public Criterion<UJO> whereIn(VALUE... list)
Create new Criterion for operator IN to compare value to a list of constants

Specified by:
whereIn in interface CriterionProvider<UJO extends Ujo,VALUE>
Parameters:
list - A collection of the values. The collection argument can be the EMPTY, the Criterion result will be FALSE in this case.
Returns:
A the new immutable Criterion

whereNotIn

public Criterion<UJO> whereNotIn(VALUE... list)
Create new Criterion for operator IN to compare value to a list of constants.

Specified by:
whereNotIn in interface CriterionProvider<UJO extends Ujo,VALUE>
Parameters:
list - A collection of the values. The collection argument can be the EMPTY, the Criterion result will be TRUE in this case.
Returns:
A the new immutable Criterion.

whereNull

public Criterion<UJO> whereNull()
Create a new Criterion where this property is null. The method is a shortcut to the next full expression:
 Criterin.where(Order.NOTE_PROPERTY, Operator.EQ, (String) null) 
for the String property type in this case.

Specified by:
whereNull in interface CriterionProvider<UJO extends Ujo,VALUE>
See Also:
#whereNotNull(org.ujorm.UjoProperty), Operator.EQ

whereNotNull

public Criterion<UJO> whereNotNull()
Create a new Criterion where this property is not null. The method is a shortcut to the next full expression:
 Criterin.where(Order.NOTE_PROPERTY, Operator.EQ, (String) null) 
for the String property type in this case.

Specified by:
whereNotNull in interface CriterionProvider<UJO extends Ujo,VALUE>
See Also:
#whereNull(org.ujorm.UjoProperty), Operator.NOT_EQ

whereNeq

public Criterion<UJO> whereNeq(VALUE value)
Create a new Criterion where this property not equals the value

Specified by:
whereNeq in interface CriterionProvider<UJO extends Ujo,VALUE>
See Also:
Operator.NOT_EQ

whereGt

public Criterion<UJO> whereGt(VALUE value)
Create a new Criterion where this property is great then the value

Specified by:
whereGt in interface CriterionProvider<UJO extends Ujo,VALUE>
See Also:
Operator.GT

whereGe

public Criterion<UJO> whereGe(VALUE value)
Create a new Criterion where this property is great or equals the value

Specified by:
whereGe in interface CriterionProvider<UJO extends Ujo,VALUE>
See Also:
Operator.GE

whereLt

public Criterion<UJO> whereLt(VALUE value)
Create a new Criterion where this property is less then the value

Specified by:
whereLt in interface CriterionProvider<UJO extends Ujo,VALUE>
See Also:
Operator.LT

whereLe

public Criterion<UJO> whereLe(VALUE value)
Create a new Criterion where this property is less or equals than the value

Specified by:
whereLe in interface CriterionProvider<UJO extends Ujo,VALUE>
See Also:
Operator.LE

forSql

public Criterion<UJO> forSql(java.lang.String sqlCondition)
Create a new Criterion for a Native Criterion in SQL statement format. Special features:

Specified by:
forSql in interface CriterionProvider<UJO extends Ujo,VALUE>
Parameters:
sqlCondition - a SQL condition in the String format, the NULL value or empty string is not accepted
See Also:
Operator.XSQL

forAll

public Criterion<UJO> forAll()
Create a new Criterion for this property where all results will be true (the result is independed on the value). The method evaluate(ujo) returns TRUE always.

Specified by:
forAll in interface CriterionProvider<UJO extends Ujo,VALUE>

forNone

public Criterion<UJO> forNone()
Create a new Criterion for this property where all results will be false (the result is independed on the value). The method evaluate(method) returns FALSE always.

Specified by:
forNone in interface CriterionProvider<UJO extends Ujo,VALUE>


Copyright © 2007-2012 PPonec