private void addFields(ParameterSignature sig, List<PotentialAssignment> list) { for (final Field field : fClass.getJavaClass().getFields()) { if (Modifier.isStatic(field.getModifiers())) { Class<?> type = field.getType(); if (sig.canAcceptArrayType(type) && field.getAnnotation(DataPoints.class) != null) { addArrayValues(field.getName(), list, getStaticFieldValue(field)); } else if (sig.canAcceptType(type) && field.getAnnotation(DataPoint.class) != null) { list.add(PotentialAssignment.forValue(field.getName(), getStaticFieldValue(field))); } } } }
@SuppressWarnings("deprecation") private void addSinglePointMethods(ParameterSignature sig, List<PotentialAssignment> list) { for (FrameworkMethod dataPointMethod : fClass.getAnnotatedMethods(DataPoint.class)) { Class<?> type = sig.getType(); if ((dataPointMethod.producesType(type))) list.add(new MethodParameterValue(dataPointMethod)); } }
@Override public List<PotentialAssignment> getValueSources(ParameterSignature signature) { SpringSyntaxTreeExamples annotation = signature.getAnnotation(SpringSyntaxTreeExamples.class); ApplicationContext ctx = new ClassPathXmlApplicationContext(annotation.contextLocation()); @SuppressWarnings("unchecked") Map<String, String> exampleMap = (Map<String, String>) ctx.getBean(annotation.exampleMap()); List<PotentialAssignment> examples = new ArrayList<>(); for (Entry<String, String> exampleEntry : exampleMap.entrySet()) { SyntaxTreeExample example = new SyntaxTreeExample(); example.setQuery(exampleEntry.getKey()); example.setSyntaxTree(exampleEntry.getValue().trim()); examples.add(example); } return examples; }