template.FilterTemplate.vsl Maven / Gradle / Ivy
## Velocity Template.
package ${functionPackage};
#foreach( $import in $imports)
import $import;
#end
/**
* generated filter function wrapper.
*
*
* - input class : {@link ${filterSubjectClass}}
*
- filter function : {@link ${targetClass}#${targetMethod}}
*
*
* @author Greg Higgins
*/
public class ${functionClass} extends AbstractFilterWrapper<${filterSubjectClass}> {
//source operand inputs
public ${sourceClass} filterSubject;
#foreach($sourceInfo in $sourceMappingList)
public ${sourceInfo.type} ${sourceInfo.id};
#end
#if(!${newFunction})
@NoEventReference
public ${targetClass} f;
#end
@NoEventReference
public Object resetNotifier;
private boolean parentReset = false;
@Initialise
public void init(){
result = false;
}
@OnEvent
@SuppressWarnings("unchecked")
public boolean onEvent(){
boolean oldValue = result;
#if(${newFunction})
result = (boolean)${targetClass}.${targetMethod}(${input});
#else
result = (boolean)f.${targetMethod}(${input});
#end
//this is probably right - to be tested
//return (!notifyOnChangeOnly | !oldValue) & result;
return (!notifyOnChangeOnly & result) | ((!oldValue) & result);
}
@OnParentUpdate("resetNotifier")
public void resetNotification(Object resetNotifier) {
parentReset = true;
if (isResetImmediate()) {
result = false;
#if(${stateful})
f.reset();
#end
parentReset = false;
}
}
@AfterEvent
public void resetAfterEvent() {
if (parentReset) {
result = false;
#if(${stateful})
f.reset();
#end
}
parentReset = false;
}
@Override
public FilterWrapper<${filterSubjectClass}> resetNotifier(Object resetNotifier) {
this.resetNotifier = resetNotifier;
return this;
}
@Override
public ${filterSubjectClass} event() {
#if(${wrappedSubject})
return (${filterSubjectClass})filterSubject.event();
#else
return filterSubject;
#end
}
@Override
public Class<${filterSubjectClass}> eventClass() {
return ${filterSubjectClass}.class;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy