template.MapperBooleanTemplate.vsl Maven / Gradle / Ivy
## Velocity Template.
package ${functionPackage};
#foreach( $import in $imports)
import $import;
#end
/**
* generated mapper function wrapper for a numeric primitive.
*
*
* - output class : {@link Boolean}
*
- input class : {@link ${filterSubjectClass}}
*
- map function : {@link ${targetClass}#${targetMethod}}
*
*
* @author Greg Higgins
*/
public class ${functionClass} extends AbstractFilterWrapper{
public ${sourceClass} filterSubject;
private boolean filterSubjectUpdated;
#foreach($sourceInfo in $sourceMappingList)
public ${sourceInfo.type} ${sourceInfo.id};
private boolean ${sourceInfo.id}Updated;
#end
#if(!${newFunction})
@NoEventReference
public ${targetClass} f;
#end
private ${outputClass} result;
#if(${stateful})
@NoEventReference
public Object resetNotifier;
private boolean parentReset = false;
#end
private boolean value;
private boolean oldValue;
@OnEvent
public boolean onEvent(){
oldValue = result;
#if(${newFunction})
result = ${targetClass}.${targetMethod}(${input});
#else
if(filterSubjectUpdated){
result = f.${targetMethod}(${input});
}
#foreach($functionInfo in $sourceFunctions)
if(${functionInfo.sourceInfo.id}Updated){
result = f.${targetMethod}(${functionInfo.paramString});
}
#end
#end
value = result;
return !notifyOnChangeOnly || (oldValue != value);
}
#if(!${newFunction})
@OnParentUpdate("filterSubject")
public void updated_filterSubject(${sourceClass} updated){
filterSubjectUpdated = true;
}
#foreach($sourceInfo in $sourceMappingList)
@OnParentUpdate("${sourceInfo.id}")
public void updated_${sourceInfo.id}(${sourceInfo.type} updated){
${sourceInfo.id}Updated = true;
}
#end
#end
#if(${stateful})
@OnParentUpdate("resetNotifier")
public void resetNotification(Object resetNotifier) {
parentReset = true;
if (isResetImmediate()) {
result = false;
f.reset();
parentReset = false;
}
}
@AfterEvent
public void resetAfterEvent() {
if (parentReset | alwaysReset) {
result = false;
f.reset();
}
parentReset = false;
}
@Override
public FilterWrapper resetNotifier(Object resetNotifier) {
this.resetNotifier = resetNotifier;
return this;
}
#end
@Override
public Boolean event() {
return value;
}
@Override
public Class eventClass() {
return Boolean.class;
}
@Initialise
public void init(){
result = false;
value = false;
oldValue = false;
#foreach($sourceInfo in $sourceMappingList)
${sourceInfo.id}Updated = false;
#end
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy