org.drools.rule.builder.dialect.java.javaRule.mvel Maven / Gradle / Ivy
@declare{"returnValueMethod"}
public static org.drools.spi.FieldValue @{methodName}(@foreach{type : declarationTypes, declr : declarations} @{type} @{declr.identifier} @end{","} @if{localDeclarations != empty && declarations != empty},@end{}
@foreach{type : localDeclarationTypes, declr : localDeclarations} @{type} @{declr.identifier} @end{","} @if{globals != empty && (localDeclarations != empty || declarations != empty)},@end{}
@foreach{type : globalTypes, identifier : globals} @{type} @{identifier} @end{","} ) throws Exception {
return org.drools.base.FieldFactory.getFieldValue( @{text} );
}
@end{}
@declare{"predicateMethod"}
public static boolean @{methodName}(@foreach{type : declarationTypes, declr : declarations} @{type} @{declr.identifier} @end{","} @if{localDeclarations != empty && declarations != empty},@end{}
@foreach{type : localDeclarationTypes, declr : localDeclarations } @{type} @{declr.identifier} @end{","} @if{globals != empty && (localDeclarations != empty || declarations != empty)},@end{}
@foreach{type : globalTypes, identifier : globals} @{type} @{identifier} @end{","} ) throws Exception {
return ( @{text} );
}
@end{}
@declare{"evalMethod"}
public static boolean @{methodName}(@foreach{type : declarationTypes, declr : declarations} @{type} @{declr.identifier} @end{","} @if{globals != empty && declarations != empty},@end{}
@foreach{type : globalTypes, identifier : globals} @{type} @{identifier} @end{","} ) throws Exception {
return ( @{text} );
}
@end{}
@declare{"accumulateInnerClass"}
public static class @{className} implements java.io.Serializable {
private static final long serialVersionUID = 400L;
@if{supportsReverse == "true"}
private java.util.Map reverseMap = new java.util.HashMap();
@end{}
@foreach{type : attributesTypes, attr : attributes} private @{type} @{attr};
@end{}
public @{className}() {
}
public void init(@foreach{type : declarationTypes, declr : declarations} @{type} @{declr.identifier}@end{","}@if{globals != empty && declarations != empty},@end{}
@foreach{type : globalTypes, identifier : globals} @{type} @{identifier} @end{","}
) throws Exception {
@{initCode}
}
public void accumulate(org.drools.WorkingMemory workingMemory,
org.drools.common.InternalFactHandle handle,
org.drools.rule.Declaration[] innerDeclarations,
Object object @if{declarations != empty}, @end{}
@foreach{type : declarationTypes, declr : declarations} @{type} @{declr.identifier}@end{","}@if{globals != empty},@end{}
@foreach{type : globalTypes, identifier : globals} @{type} @{identifier} @end{","}@if{innerDeclarations != empty},@end{}
@foreach{declr : innerDeclarations}@{declr.extractor.extractToClassName} @{declr.identifier}@end{","}
) throws Exception {
@if{supportsReverse == "true"}
this.reverseMap.put( Integer.valueOf( handle.getId() ),
new ReverseSnapshot(
@foreach{declr : declarations}@{declr.identifier}@end{","}@if{innerDeclarations != empty && declarations != empty},@end{}
@foreach{declr : innerDeclarations}@{declr.identifier}@end{","}
) );
@end{}
@{actionCode}
}
public void reverse(org.drools.WorkingMemory workingMemory,
org.drools.common.InternalFactHandle handle,
Object object@if{globals != empty},@end{}
@foreach{type : globalTypes, identifier : globals} @{type} @{identifier} @end{","}
) throws Exception {
@if{supportsReverse == "true"}
ReverseSnapshot snapshot = (ReverseSnapshot) this.reverseMap.remove( Integer.valueOf( handle.getId() ) );
@foreach{type : declarationTypes, declr : declarations}@{type} @{declr.identifier} = snapshot.@{declr.identifier};@end{}
@foreach{declr : innerDeclarations}@{declr.extractor.extractToClassName} @{declr.identifier} = snapshot.@{declr.identifier};@end{}
@end{}
@{reverseCode}
}
public Object getResult(@foreach{type : declarationTypes, declr : declarations} @{type} @{declr.identifier}@end{","}@if{globals != empty && declarations != empty},@end{}
@foreach{type : globalTypes, identifier : globals}@{type} @{identifier} @end{","}
) throws Exception {
return ( @{resultCode} );
}
public boolean supportsReverse() {
return @{supportsReverse};
}
@if{supportsReverse == "true"}
private static class ReverseSnapshot implements java.io.Serializable {
@foreach{type : declarationTypes, declr : declarations} public final @{type} @{declr.identifier};@end{}
@foreach{declr : innerDeclarations}public final @{declr.extractor.extractToClassName} @{declr.identifier};@end{}
public ReverseSnapshot(@foreach{type : declarationTypes, declr : declarations}final @{type} @{declr.identifier}@end{","}@if{innerDeclarations != empty && declarations != empty},@end{}
@foreach{declr : innerDeclarations}final @{declr.extractor.extractToClassName} @{declr.identifier}@end{","}
) {
@foreach{type : declarationTypes, declr : declarations}this.@{declr.identifier} = @{declr.identifier};@end{}
@foreach{declr : innerDeclarations}this.@{declr.identifier} = @{declr.identifier};@end{}
}
}
@end{}
}
@end{}
@declare{"consequenceMethod"}
public static void @{methodName}(org.drools.spi.KnowledgeHelper drools@if{declarations != empty},@end{} @foreach{type : declarationTypes, declr : declarations} @{type} @{declr.identifier}, org.drools.FactHandle @{declr.identifier}__Handle__ @end{","}@if{globals != empty},@end{} @foreach{type : globalTypes, identifier : globals} @{type} @{identifier} @end{","} ) throws Exception { org.drools.runtime.rule.RuleContext kcontext = drools;
@{text}
}
@end{}
@declare{"actionMethod"}
public static void @{methodName}(org.drools.spi.KnowledgeHelper drools@if{globals != empty},@end{} @foreach{type :globalTypes, identifier : globals} @{type} @{identifier} @end{","}, org.drools.spi.ProcessContext context ) throws Exception {
org.drools.runtime.process.ProcessContext kcontext = context;
@{text}
}
@end{}
@declare{"returnValueEvaluatorMethod"}
public static Object @{methodName}(@foreach{type : globalTypes, identifier : globals} @{type} @{identifier} @end{","} ) throws Exception {
@{text}
}
@end{}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy