org.expasy.jpl.commons.base.cond
Class ConditionImpl<T,V>

java.lang.Object
  extended by org.expasy.jpl.commons.base.cond.ConditionImpl<T,V>
Type Parameters:
T - user's object that will be tested against .
V - value to match to satisfy the condition.
All Implemented Interfaces:
org.apache.commons.collections15.Predicate<T>, Condition<T>

public final class ConditionImpl<T,V>
extends Object
implements Condition<T>

Conditional statement where a T-object may meet the condition on a V-value given an operator.

Version:
1.0
Author:
nikitin

Nested Class Summary
static class ConditionImpl.Builder<T,V>
          A builder to ease the construction of conditions
static class ConditionImpl.ConditionRuntimeException
          Thrown when condition problem met.
 
Method Summary
 boolean evaluate(T object)
          Test if this condition is valid for the given object
 boolean evaluate(TypedDataContainer input)
           
 Set<String> getDependentVariables()
           
 String getName()
          the name (have to respect the file name convention)
 Operator<Object,V> getOperator()
          
 V getROperand()
           
static
<T,V> String
getStackCommands(ConditionImpl<T,V> cond, V value)
           
 boolean isNotCondition()
          
 void printStackCommands()
          Trace tree expression stack status
 String toString()
           
static
<T,V> ConditionImpl<T,V>
valueOf(String condition)
          Factory method for numerical condition types.
static
<T,V> ConditionImpl<T,V>
valueOf(String operator, String rvalue)
           
static
<T,V> ConditionImpl<T,V>
valueOf(String lvalueName, String operator, String rvalue)
          Factory method for numerical condition types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getOperator

public Operator<Object,V> getOperator()

Specified by:
getOperator in interface Condition<T>
Returns:
operator

isNotCondition

public boolean isNotCondition()

Specified by:
isNotCondition in interface Condition<T>
Returns:
true if the condition is applying the not operator

evaluate

public boolean evaluate(T object)
Test if this condition is valid for the given object

Specified by:
evaluate in interface org.apache.commons.collections15.Predicate<T>
Parameters:
object - the object to test condition on
Returns:
true if valid condition

evaluate

public boolean evaluate(TypedDataContainer input)
Specified by:
evaluate in interface Condition<T>
Returns:
true if the input (many possible variables) satisfy the condition

printStackCommands

public void printStackCommands()
Trace tree expression stack status

Specified by:
printStackCommands in interface Condition<T>

getDependentVariables

public Set<String> getDependentVariables()
Specified by:
getDependentVariables in interface Condition<T>
Returns:
the set of condition-dependent variable names

getROperand

public V getROperand()

getStackCommands

public static <T,V> String getStackCommands(ConditionImpl<T,V> cond,
                                            V value)

getName

public String getName()
Description copied from interface: Condition
the name (have to respect the file name convention)

Specified by:
getName in interface Condition<T>

valueOf

public static <T,V> ConditionImpl<T,V> valueOf(String lvalueName,
                                               String operator,
                                               String rvalue)
                                  throws BuilderException
Factory method for numerical condition types.

Parameters:
operator - the operator string.
rvalue - the rvalue string.
Returns:
a new instance of ConditionImpl
Throws:
BuilderException

valueOf

public static <T,V> ConditionImpl<T,V> valueOf(String operator,
                                               String rvalue)
                                  throws BuilderException
Throws:
BuilderException

valueOf

public static <T,V> ConditionImpl<T,V> valueOf(String condition)
                                  throws BuilderException
Factory method for numerical condition types.

Parameters:
condition - the condition string to convert into ConditionImpl
Returns:
a new instance of ConditionImpl
Throws:
OperatorNotFoundRTException
BuilderException

toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2012 Swiss Institute of Bioinformatics. All rights reserved.