
template.FunctionsTemplate.vsl Maven / Gradle / Ivy
## Velocity Template
/*
* Copyright (C) 2019 V12 Technology Ltd.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* .
*/
package ${package};
#foreach( $import in $imports)
import $import;
#end
/**
* Utility class providing static helper methods to create mapping operations
* in streams from a set of wrapped functions.
*
* This class is autogenerated from executing {@link StreamFunctionGenerator}
*
* @author Greg Higgins
*/
public class ${className} {
#foreach( $FunctionInfo in $bifunctions)
public static SerializableBiFunction ${FunctionInfo.functionName}() {
return ${FunctionInfo.invoke};
}
public static Wrapper<${FunctionInfo.returnType}> ${FunctionInfo.functionName}(SerializableFunction supplier1, SerializableFunction supplier2) {
return FilterBuilder.map(${FunctionInfo.invoke}, arg(supplier1), arg(supplier2));
}
public static Wrapper<${FunctionInfo.returnType}> ${FunctionInfo.functionName}(SerializableSupplier supplier1, SerializableSupplier supplier2) {
return FilterBuilder.map(${FunctionInfo.invoke}, arg(supplier1), arg(supplier2));
}
public static Wrapper<${FunctionInfo.returnType}> ${FunctionInfo.functionName}(FunctionArg arg1, FunctionArg arg2) {
return FilterBuilder.map(${FunctionInfo.invoke}, arg1, arg2);
}
public static Wrapper<${FunctionInfo.returnType}> ${FunctionInfo.functionName}(Wrapper wrapper, SerializableFunction supplier1, SerializableFunction supplier2) {
return FilterBuilder.map(${FunctionInfo.invoke}, arg(wrapper, supplier1), arg(wrapper, supplier2));
}
public static Wrapper<${FunctionInfo.returnType}> ${FunctionInfo.functionName}(Wrapper wrapper1, SerializableFunction supplier1, Wrapper wrapper2, SerializableFunction supplier2) {
return FilterBuilder.map(${FunctionInfo.invoke}, arg(wrapper1, supplier1), arg(wrapper2, supplier2));
}
public static Wrapper<${FunctionInfo.returnType}> ${FunctionInfo.functionName}(Wrapper wrapper1, Wrapper wrapper2) {
return FilterBuilder.map(${FunctionInfo.invoke}, arg(wrapper1), arg(wrapper2));
}
#end
#foreach( $FunctionInfo in $functions)
/**
* Wrap {@link ${FunctionInfo.methodName} } function for use as a map operation in an existing
* stream. {@link Wrapper#map(SerializableFunction) }
* requires a {@link SerializableFunction} to map input values.
*
* @param input to {@link ${FunctionInfo.methodName} }
* @return {@link SerializableFunction} of {@link ${FunctionInfo.methodName} }
*/
public static SerializableFunction ${FunctionInfo.functionName}() {
return ${FunctionInfo.invoke};
}
/**
* Performs a {@link ${FunctionInfo.methodName}} function as a map operation on a stream.
* The stream is automatically created by subscribing to the {@link Event}
* and wrapping the supplier function with {@link Wrapper<${FunctionInfo.inputType}>}.
* The wrapper is the input to the mapping function. The mapped value is available as
* a {@link Wrapper<${FunctionInfo.returnType}>} instance for further stream operations.
*
* @param The input event stream
* @param supplier The input value to the function {@link ${FunctionInfo.methodName}
* @return {@link Wrapper<${FunctionInfo.returnType}>} wrapping the result of {@link ${FunctionInfo.methodName}}
*/
public static Wrapper<${FunctionInfo.returnType}> ${FunctionInfo.functionName}(SerializableFunction supplier) {
return FilterBuilder.map(${FunctionInfo.invoke}, arg(supplier));
}
public static Wrapper<${FunctionInfo.returnType}> ${FunctionInfo.functionName}(FunctionArg arg) {
return FilterBuilder.map(${FunctionInfo.invoke}, arg);
}
/**
* Performs a {@link ${FunctionInfo.methodName}} function as a map operation on a stream.
* The stream is automatically created by wrapping the supplier instance function in a
* {@link Wrapper<${FunctionInfo.inputType}>}, the wrapper is the input
* to the mapping function. The mapped value is available as
* a {@link Wrapper<${FunctionInfo.returnType}>} instance for further stream operations.
*
* @param The input type required by {@link ${FunctionInfo.methodName}}
* @param supplier The wrapped instance supplying values to the function {@link ${FunctionInfo.methodName}
* @return {@link Wrapper<${FunctionInfo.returnType}>} wrapping the result of {@link ${FunctionInfo.methodName}}
*/
public static Wrapper<${FunctionInfo.returnType}> ${FunctionInfo.functionName}(SerializableSupplier supplier) {
return FilterBuilder.map(${FunctionInfo.invoke}, arg(supplier));
}
public static Wrapper<${FunctionInfo.returnType}> ${FunctionInfo.functionName}(Wrapper wrapper, SerializableFunction supplier) {
return FilterBuilder.map(${FunctionInfo.invoke}, arg(wrapper, supplier));
}
public static Wrapper<${FunctionInfo.returnType}> ${FunctionInfo.functionName}(Wrapper wrapper) {
return FilterBuilder.map(${FunctionInfo.invoke}, arg(wrapper));
}
#end
#foreach( $FunctionInfo in $consumers)
/**
* Wrap {@link ${FunctionInfo.methodName} } function for use as a map operation in an existing
* stream. {@link Wrapper#map(SerializableFunction) }
* requires a {@link SerializableFunction} to map input values.
*
* @param input to {@link ${FunctionInfo.methodName} }
* @return {@link SerializableFunction} of {@link ${FunctionInfo.methodName} }
*/
public static SerializableFunction ${FunctionInfo.functionName}() {
return ${FunctionInfo.invoke};
}
/**
* Performs a {@link ${FunctionInfo.methodName}} function as a map operation on a stream.
* The stream is automatically created by subscribing to the {@link Event}
* and wrapping the supplier function with {@link Wrapper<T>}.
* The wrapper is the input to the mapping function. The mapped value is available as
* a {@link Wrapper<${FunctionInfo.returnType}>} instance for further stream operations.
*
* @param The input event stream
* @return {@link Wrapper<${FunctionInfo.returnType}>} wrapping the result of {@link ${FunctionInfo.methodName}}
*/
public static Wrapper<${FunctionInfo.returnType}> ${FunctionInfo.functionName}(Class eventClass) {
return select(eventClass).map(${FunctionInfo.invoke});
}
/**
* Performs a {@link ${FunctionInfo.methodName}} function as a map operation on a stream.
* The stream is automatically created by wrapping the supplier instance function in a
* {@link Wrapper<T>}, the wrapper is the input
* to the mapping function. The mapped value is available as
* a {@link Wrapper<${FunctionInfo.returnType}>} instance for further stream operations.
*
* @param The input type required by {@link ${FunctionInfo.methodName}}
* @param supplier The wrapped instance supplying values to the function {@link ${FunctionInfo.methodName}
* @return {@link Wrapper<${FunctionInfo.returnType}>} wrapping the result of {@link ${FunctionInfo.methodName}}
*/
public static Wrapper<${FunctionInfo.returnType}> ${FunctionInfo.functionName}(T supplier) {
return stream(supplier).map(${FunctionInfo.invoke});
}
#end
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy