@SuppressWarnings("unused") protected final MethodSpec createDefaultMethodSpec(ExecutableElement method, AnnotationMirror mirror, boolean shortCircuitsEnabled, String shortCircuitName) { MethodSpec methodSpec = new MethodSpec(createReturnParameterSpec()); addDefaultFrame(methodSpec); addDefaultFieldMethodSpec(methodSpec); addDefaultChildren(shortCircuitName, methodSpec); return methodSpec; }
private void addDefaultChildren(String breakName, MethodSpec spec) { if (getNode().getChildren() == null) { // children are null when parsing executable types return; } for (NodeExecutionData execution : getNode().getChildExecutions()) { if (breakName != null && execution.getIndexedName().equals(breakName)) { break; } spec.addRequired(createValueParameterSpec(execution)); } }
@Override public boolean isParsable(ExecutableElement method) { if (getAnnotationType() != null) { return ElementUtils.findAnnotationMirror(getContext().getEnvironment(), method, getAnnotationType()) != null; } return true; }
private void addDefaultChildren(boolean shortCircuitsEnabled, String breakName, MethodSpec spec) { if (getNode().getChildren() == null) { // children are null when parsing executable types return; } for (NodeExecutionData execution : getNode().getChildExecutions()) { if (breakName != null && execution.getIndexedName().equals(breakName)) { break; } if (execution.isShortCircuit() && shortCircuitsEnabled) { spec.addRequired(new ParameterSpec(shortCircuitValueName(execution.getName()), getContext().getType(boolean.class))); } spec.addRequired(createValueParameterSpec(execution)); } }
protected Collection<TypeMirror> getPossibleParameterTypes(NodeExecutionData execution) { return getNode().getGenericTypes(execution); }
protected ParameterSpec createReturnParameterSpec() { ParameterSpec returnValue = new ParameterSpec("returnValue", getPossibleReturnTypes()); returnValue.setExecution(getNode().getThisExecution()); return returnValue; }
protected ParameterSpec createValueParameterSpec(NodeExecutionData execution) { ParameterSpec spec = new ParameterSpec(execution.getName(), getPossibleParameterTypes(execution)); spec.setExecution(execution); return spec; }
@Override protected ParameterSpec createValueParameterSpec(NodeExecutionData execution) { ParameterSpec parameterSpec = super.createValueParameterSpec(execution); parameterSpec.setAllowSubclasses(false); return parameterSpec; }
protected Collection<TypeMirror> getPossibleParameterTypes(NodeExecutionData execution) { return getNode().getGenericTypes(execution); }
protected ParameterSpec createReturnParameterSpec() { ParameterSpec returnValue = new ParameterSpec("returnValue", getPossibleReturnTypes()); returnValue.setExecution(getNode().getThisExecution()); return returnValue; }
protected ParameterSpec createValueParameterSpec(NodeExecutionData execution) { ParameterSpec spec = new ParameterSpec(execution.getName(), getPossibleParameterTypes(execution)); spec.setExecution(execution); return spec; }
@SuppressWarnings("unused") protected final MethodSpec createDefaultMethodSpec(ExecutableElement method, AnnotationMirror mirror, boolean shortCircuitsEnabled, String shortCircuitName) { MethodSpec methodSpec = new MethodSpec(createReturnParameterSpec()); addDefaultFrame(methodSpec); addDefaultFieldMethodSpec(methodSpec); addDefaultChildren(shortCircuitsEnabled, shortCircuitName, methodSpec); return methodSpec; }
@Override public boolean isParsable(ExecutableElement method) { if (getAnnotationType() != null) { return ElementUtils.findAnnotationMirror(getContext().getEnvironment(), method, getAnnotationType()) != null; } return true; }
protected void addDefaultFieldMethodSpec(MethodSpec methodSpec) { for (NodeFieldData field : getNode().getFields()) { if (field.getGetter() == null) { ParameterSpec spec = new ParameterSpec(field.getName(), field.getType()); spec.setLocal(true); methodSpec.addOptional(spec); } } }
protected void addDefaultFieldMethodSpec(MethodSpec methodSpec) { for (NodeFieldData field : getNode().getFields()) { if (field.getGetter() == null) { ParameterSpec spec = new ParameterSpec(field.getName(), field.getType()); spec.setLocal(true); methodSpec.addOptional(spec); } } }