public static ImplementationDependency createDependency(Annotation annotation, Set<String> literalParameters) { if (annotation instanceof TypeParameter) { return new TypeImplementationDependency(((TypeParameter) annotation).value()); } if (annotation instanceof LiteralParameter) { return new LiteralImplementationDependency(((LiteralParameter) annotation).value()); } if (annotation instanceof FunctionDependency) { FunctionDependency functionDependency = (FunctionDependency) annotation; return new FunctionImplementationDependency( functionDependency.name(), parseTypeSignature(functionDependency.returnType(), literalParameters), Arrays.stream(functionDependency.argumentTypes()) .map(signature -> parseTypeSignature(signature, literalParameters)) .collect(toImmutableList()), toInvocationConvention(functionDependency.convention())); } if (annotation instanceof OperatorDependency) { OperatorDependency operatorDependency = (OperatorDependency) annotation; return new OperatorImplementationDependency( operatorDependency.operator(), parseTypeSignature(operatorDependency.returnType(), literalParameters), Arrays.stream(operatorDependency.argumentTypes()) .map(signature -> parseTypeSignature(signature, literalParameters)) .collect(toImmutableList()), toInvocationConvention(operatorDependency.convention())); } throw new IllegalArgumentException("Unsupported annotation " + annotation.getClass().getSimpleName()); }
public static ImplementationDependency createDependency(Annotation annotation, Set<String> literalParameters) { if (annotation instanceof TypeParameter) { return new TypeImplementationDependency(((TypeParameter) annotation).value()); } if (annotation instanceof LiteralParameter) { return new LiteralImplementationDependency(((LiteralParameter) annotation).value()); } if (annotation instanceof FunctionDependency) { FunctionDependency functionDependency = (FunctionDependency) annotation; return new FunctionImplementationDependency( functionDependency.name(), parseTypeSignature(functionDependency.returnType(), literalParameters), Arrays.stream(functionDependency.argumentTypes()) .map(signature -> parseTypeSignature(signature, literalParameters)) .collect(toImmutableList()), toInvocationConvention(functionDependency.convention())); } if (annotation instanceof OperatorDependency) { OperatorDependency operatorDependency = (OperatorDependency) annotation; return new OperatorImplementationDependency( operatorDependency.operator(), parseTypeSignature(operatorDependency.returnType(), literalParameters), Arrays.stream(operatorDependency.argumentTypes()) .map(signature -> parseTypeSignature(signature, literalParameters)) .collect(toImmutableList()), toInvocationConvention(operatorDependency.convention())); } throw new IllegalArgumentException("Unsupported annotation " + annotation.getClass().getSimpleName()); }