@SuppressWarnings("unchecked") public static String getAnnotationString(Annotated<?> annotated, Class annotationClass, String missingValue) { AbstractTextualValueAssertion a = (AbstractTextualValueAssertion) getAnnotation( annotated, annotationClass); if (a == null) { return missingValue; } return a.getText(); }
private Processor createNestingProcessor(List<Edit<?>> editList) { Processor nestingProcessor = edits.createProcessor(uniqueProcessorName( nameField.getText(), currentDataflow)); if (includedProcessors.size() != 1 || !(includedProcessors.get(0) instanceof Processor)) return nestingProcessor; Processor includedProcessor = (Processor) includedProcessors.get(0); for (Class<?> c : at.getAnnotatingClasses(includedProcessor)) { AnnotationBeanSPI annotation = at.getAnnotation(includedProcessor, AbstractTextualValueAssertion.class); if ((annotation != null) && (annotation instanceof AbstractTextualValueAssertion)) editList.add(at.setAnnotationString(nestingProcessor, c, ((AbstractTextualValueAssertion) annotation).getText())); } return nestingProcessor; }
/** * Add the identification of a Dataflow into its identification annotation chain (if necessary) * * @return Whether an identification needed to be added */ public static boolean addDataflowIdentification(Dataflow dataflow, String internalId, Edits edits) { boolean added = false; IdentificationAssertion ia = (IdentificationAssertion) (AnnotationTools.getAnnotation(dataflow, IdentificationAssertion.class)); if ((ia == null) || !ia.getIdentification().equals(internalId)) { IdentificationAssertion newIa = new IdentificationAssertion(); newIa.setIdentification(internalId); try { AnnotationTools.addAnnotation(dataflow, newIa, edits).doEdit(); } catch (EditException e) { added = false; } } return added; }