![JAR search and dependency download from the Maven repository](/logo.png)
spoon.examples.distcalc.template.ServicesImplTemplate Maven / Gradle / Ivy
The newest version!
package spoon.examples.distcalc.template;
import java.util.ArrayList;
import java.util.List;
import spoon.examples.distcalc.MemoryCell;
import spoon.examples.distcalc.processing._NodeInterf_;
import spoon.reflect.declaration.CtParameter;
import spoon.reflect.reference.CtTypeReference;
import spoon.template.Local;
import spoon.template.Parameter;
import spoon.template.Template;
public class ServicesImplTemplate implements Template {
@Parameter
List> _parameters_;
@Parameter("_nodes_")
String __nodes_;
@Parameter
String _serviceName_;
@Parameter
Class> _ReturnType_;
@Parameter
CtTypeReference> _NodeInterf_;
@Parameter
CtTypeReference> _NodeImpl_;
@Parameter
CtTypeReference> _MemoryCellType_;
@Local
public ServicesImplTemplate(CtTypeReference> nodeImplType, CtTypeReference> nodeType, CtTypeReference> memType,
Class> returnType, String serviceName, List> parameters) {
this._parameters_ = parameters;
this.__nodes_ = serviceName + "_" + "nodes";
this._ReturnType_ = returnType;
this._NodeInterf_ = nodeImplType;
this._NodeImpl_ = nodeType;
this._serviceName_ = serviceName;
this._MemoryCellType_ = memType;
}
public static List<_NodeInterf_> _nodes_ = new ArrayList<_NodeInterf_>();
@Local
void initializer() {
ServicesImplTemplate._nodes_.add(new _NodeImpl_());
}
public _ReturnType_ _serviceName_(List> _parameters_) {
_NodeInterf_ node = null;
for (_NodeInterf_ f : _nodes_) {
if (f.canProceed(_parameters_)) {
node = f;
break;
}
}
if (node != null) {
if (node instanceof MemoryCell) {
return node.proceed(_parameters_);
} else {
_ReturnType_ result = node.proceed(_parameters_);
_nodes_.add(0, new _MemoryCellType_(result,_parameters_));
return result;
}
} else {
throw new RuntimeException("cannot calculate");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy