com.dooapp.gaedo.finders.collections.AbstractBasicEvaluator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gaedo-collections Show documentation
Show all versions of gaedo-collections Show documentation
Contains the collections implementation, and only depend upon gaedo-definition
package com.dooapp.gaedo.finders.collections;
import java.lang.reflect.Field;
import com.dooapp.gaedo.CrudServiceException;
import com.dooapp.gaedo.properties.Property;
/**
* Root class for simple evaluators
* @author ndx
*
* @param
*/
public abstract class AbstractBasicEvaluator implements Evaluator {
static class NonExistentFieldException extends CrudServiceException {
public NonExistentFieldException(Property field, Object element) {
super("The field \"" +
field.toGenericString()+
"\"does not exists for class \""+element.getClass().getName()+"\"");
}
}
/**
* Field to introspect
*/
private final Property source;
public AbstractBasicEvaluator(Property source) {
super();
this.source = source;
}
/**
* Common implementation of reflection-backed value getter
* @param element
* @return
*/
protected Object getValue(DataType element) {
try {
if(source==null)
return element;
else
return source.get(element);
} catch (Exception e) {
throw new NonExistentFieldException(source, element);
}
}
/**
* Basic evaluators never support adding subevaluators; As a consequence, they always fire an {@link UnsupportedOperationException}
*/
public final void add(Evaluator subEvaluator) {
throw new UnsupportedOperationException("don't thing about adding a child evaluator to a basic condition "+getClass().getSimpleName()+" man !");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy