org.ujoframework.criterion
Class Criterion<UJO extends Ujo>

java.lang.Object
  extended by org.ujoframework.criterion.Criterion<UJO>
Direct Known Subclasses:
BinaryCriterion, ValueCriterion

public abstract class Criterion<UJO extends Ujo>
extends java.lang.Object

An abstract criterion provides a basic interface and static factory methods. You can use it:

There is allowed to join two instances (based on the same BO) to a binary tree by a new Criterion. Some common operators (and, or, not) are implemeted into a special join method of the Criteron class.

Example of use

// Make a criterion:
 Criterion<Person> crn1 = Criterion.newInstance(CASH, Operator.GT, 10.0);
 Criterion<Person> crn2 = Criterion.newInstance(CASH, Operator.LE, 20.0);
 Criterion<Person> criterion = crn1.and(crn2);

 // Use a criterion (1):
 CriteriaTool<Person> ct = CriteriaTool.newInstance();
 List<Person> result = ct.select(persons, criterion);
 assertEquals(1, result.size());
 assertEquals(20.0, CASH.of(result.get(0)));

 // Use a criterion (2):
 Person person = result.get(0);
 boolean validation = criterion.evaluate(person);
 assertTrue(validation);
 

Since:
0.90
Author:
Pavel Ponec

Constructor Summary
Criterion()
           
 
Method Summary
 Criterion<UJO> and(Criterion<UJO> criterion)
           
abstract  boolean evaluate(UJO ujo)
           
abstract  java.lang.Object getLeftNode()
          Returns the left node of the parrent
abstract  AbstractOperator getOperator()
          Returns an operator
abstract  java.lang.Object getRightNode()
          Returns the right node of the parrent
 boolean isBinary()
          Is a Binary criterion?
 Criterion<UJO> join(BinaryOperator operator, Criterion<UJO> criterion)
           
static
<UJO extends Ujo>
Criterion<UJO>
newInstance(boolean value)
          This is an constane criterion independed on an entity.
static
<UJO extends Ujo,TYPE>
Criterion<UJO>
newInstance(UjoProperty<UJO,TYPE> property)
          New equals instance
static
<UJO extends Ujo,TYPE>
Criterion<UJO>
newInstance(UjoProperty<UJO,TYPE> property, Operator operator, TYPE value)
          New criterion instance
static
<UJO extends Ujo,TYPE>
Criterion<UJO>
newInstance(UjoProperty<UJO,TYPE> property, Operator operator, UjoProperty<?,TYPE> value)
          New criterion instance
static
<UJO extends Ujo,TYPE>
Criterion<UJO>
newInstance(UjoProperty<UJO,TYPE> property, TYPE value)
          New equals instance
static
<UJO extends Ujo,TYPE>
Criterion<UJO>
newInstance(UjoProperty<UJO,TYPE> property, UjoProperty<?,TYPE> value)
          New equals instance
static
<UJO extends Ujo>
Criterion<UJO>
newInstanceFalse(UjoProperty<UJO,?> property)
          This is a constant criterion independed on the property and the ujo entity.
static
<UJO extends Ujo>
Criterion<UJO>
newInstanceTrue(UjoProperty<UJO,?> property)
          This is a constant criterion independed on the property and the ujo entity.
 Criterion<UJO> not()
           
 Criterion<UJO> or(Criterion<UJO> criterion)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Criterion

public Criterion()
Method Detail

evaluate

public abstract boolean evaluate(UJO ujo)

join

public Criterion<UJO> join(BinaryOperator operator,
                           Criterion<UJO> criterion)

and

public Criterion<UJO> and(Criterion<UJO> criterion)

or

public Criterion<UJO> or(Criterion<UJO> criterion)

not

public Criterion<UJO> not()

getLeftNode

public abstract java.lang.Object getLeftNode()
Returns the left node of the parrent


getRightNode

public abstract java.lang.Object getRightNode()
Returns the right node of the parrent


getOperator

public abstract AbstractOperator getOperator()
Returns an operator


newInstance

public static <UJO extends Ujo,TYPE> Criterion<UJO> newInstance(UjoProperty<UJO,TYPE> property,
                                                                Operator operator,
                                                                TYPE value)
New criterion instance

Parameters:
property - UjoProperty
operator - Operator
  • VALUE - the parameter value
  • UjoProperty - reference to a related entity
  • List<TYPE> - list of values (TODO)
  • THE SAME property - the value will be assigned using the property later (TODO)
Returns:
A new criterion

newInstance

public static <UJO extends Ujo,TYPE> Criterion<UJO> newInstance(UjoProperty<UJO,TYPE> property,
                                                                Operator operator,
                                                                UjoProperty<?,TYPE> value)
New criterion instance

Parameters:
property - UjoProperty
operator - Operator
  • VALUE - the parameter value
  • UjoProperty - reference to a related entity
  • List<TYPE> - list of values (TODO)
  • THE SAME property - the value will be assigned using the property later (TODO)
Returns:
A new criterion

newInstance

public static <UJO extends Ujo,TYPE> Criterion<UJO> newInstance(UjoProperty<UJO,TYPE> property,
                                                                TYPE value)
New equals instance

Parameters:
property - UjoProperty
  • TYPE - parameter value
  • List<TYPE> - list of values
  • UjoProperty - reference to a related entity
  • THE SAME property - the value will be assigned using the property later
Returns:
A the new Criterion

newInstance

public static <UJO extends Ujo,TYPE> Criterion<UJO> newInstance(UjoProperty<UJO,TYPE> property,
                                                                UjoProperty<?,TYPE> value)
New equals instance

Parameters:
property - UjoProperty
value - Value or UjoProperty can be type of
  • TYPE - parameter value
  • List<TYPE> - list of values
  • UjoProperty - reference to a related entity
  • THE SAME property - the value will be assigned using the property later
Returns:
A the new Criterion

newInstance

public static <UJO extends Ujo,TYPE> Criterion<UJO> newInstance(UjoProperty<UJO,TYPE> property)
New equals instance

Parameters:
property - UjoProperty
  • TYPE - parameter value
  • List<TYPE> - list of values
  • UjoProperty - reference to a related entity
  • THE SAME property - the value will be assigned using the property later

newInstance

public static <UJO extends Ujo> Criterion<UJO> newInstance(boolean value)
This is an constane criterion independed on an entity. It is recommended not to use this solution in ORM.


newInstanceTrue

public static <UJO extends Ujo> Criterion<UJO> newInstanceTrue(UjoProperty<UJO,?> property)
This is a constant criterion independed on the property and the ujo entity. A result is the TRUE allways.


newInstanceFalse

public static <UJO extends Ujo> Criterion<UJO> newInstanceFalse(UjoProperty<UJO,?> property)
This is a constant criterion independed on the property and the ujo entity. A result is the FALSE allways.


isBinary

public boolean isBinary()
Is a Binary criterion?



Copyright © 2009. All Rights Reserved.