org.nakedobjects.noa.reflect.NakedObjectActionParameter Maven / Gradle / Ivy
package org.nakedobjects.noa.reflect;
import org.nakedobjects.noa.adapter.NakedObject;
import org.nakedobjects.noa.spec.HasType;
public interface NakedObjectActionParameter extends NakedObjectFeature {
// needs to be public for jsharp compiler
public interface Filter {
boolean accept(NakedObjectActionParameter noap);
}
/**
* Filters only parameters that are for values (ie 1:1 associations)
*/
Filter VALUES = new Filter() {
public boolean accept(NakedObjectActionParameter parameter) {
return parameter.getSpecification().getType() == HasType.VALUE;
}
};
/**
* Filters only parameters that are for objects (ie 1:1 associations)
*/
Filter ASSOCIATIONS = new Filter() {
public boolean accept(NakedObjectActionParameter parameter) {
return parameter.getSpecification().getType() == HasType.OBJECT;
}
};
/**
* If true then can cast to a {@link OneToOneActionParameter}.
*
*
* Either this or {@link #isValue()} will be true.
*
*
* Design note: modelled after {@link NakedObjectField#isObject()}
*/
boolean isObject();
/**
* If true then can cast to a {@link ValueActionParameter}.
*
*
* Either this or {@link #isObject()} will be true.
*
*
* Design note: modelled after {@link NakedObjectField#isValue()}
*/
boolean isValue();
/**
* Only for symmetry with {@link NakedObjectField}, however since the NOF does not support collections as
* actions all implementations should return false.
*/
boolean isCollection();
/**
* Owning {@link NakedObjectAction}.
*/
NakedObjectAction getAction();
/**
* Returns a flag indicating if it can be left unset when the action can be invoked.
*/
boolean isOptional();
/**
* Returns the 0-based index to this parameter.
*/
int getNumber();
/**
* Whether proposed value for this parameter is valid.
*
* @param nakedObject
* @param proposedValue
* @return
*/
String isValid(NakedObject nakedObject, Object proposedValue);
}