like paradise

Illusion

Even paradise can't exists without retentions. The more exists in real life. That's what's the interface ConditionElement is all about. That interface has nothing in common with hair care - it serves to restrict the access to persistent data.

To relax usage of condition elements, the same translation helper will be used as at writing or reading entities.

EqualConditionElement

public EqualConditionElement(String name, Object value);
   

The matching entity must have a property named by "name". The condition matches all instances, where the value of the named property equals the value given. There's no need to require value be of the same type as the named property of the matching entity. There only need to exists a Converter that could translate one type into the other.

NotEqualConditionElement

public NotEqualConditionElement(String name, Object value);
   

Is the opposite of EqualConditionElement.

InListConditionElement

This condition is the lady luck.

public InListConditionElement(String name, List values);

public InListConditionElement(String name, Object[] values);
The condition matches all instances, having the named property a value contained in the list of values. The list of values can be passed as java List or as a static array. As before, same is true for the type of values. They don't need to be equal, but there must exists a Converter...

LowerBoundConditionElement

Border control!

public LowerBoundConditionElement(String name, Object value);

public LowerBoundConditionElement(String name, Object value, boolean includeBoundary);
The condition matches all instances, where the value of the named property is bigger than the given "value". You can optionally specify, whether the given border value shall be included in the result list. Default is not to accempt the border value as part of the result.

UpperBoundConditionElement

border control - from the other side of the fence!

public UpperBoundConditionElement(String name, Object value);

public UpperBoundConditionElement(String name, Object value, boolean includeBoundary);
The condition matches all instances, where the value of the named property is smaller than the given "value". You can optionally specify whether the given border value shall be included in the result list. Default is to not accept the border value as result.

SearchConditionElement

do I like the pattern?

public SearchConditionElement(String name, Object value);
   
This condition executes a pattern search at the named property. Therefore the given value should contain a wildcard. If it does not contain a wildcard, the value will be extended with wildcards at each side, so the value should exists somewhere in the property value of the instance to check. It should be obvious, that search condition could only be used for textual attributes.

MinConditionElement

Who has the smallest ...?

public MinConditionElement(String name);
   
This condition takes no value. The database determines the smallest value for the named property and returns a single instance.

MaxConditionElement

Who is the king of all?

public MaxConditionElement(String name);
   
This condition takes no value. The database determines the biggest entry of the named property and returns a single instance.

AlternatingSequence

Usually all conditions must met at the same time. If you like to create a somewhat relaxed condition, you could use AlternatingSequence.

AlternatingSequence is not a condition by itself, but takes a list of conditions and one out of the bunch must met.

public AlternatingSequence(ConditionElement[] elems);

public AlternatingSequence(List args);
   
As before, the list can be passed as java List or as a statically array.