/** * This method uses for validate @Extension / @Example elements. * * @param examples examples array which needs to be validate. * @throws AnnotationValidationException whenever if the validate rule violate, throws the annotation validate * exception with proper message. */ public void examplesValidation(Example[] examples) throws AnnotationValidationException { //Check if the @Example annotated in all the @Extension classes. if (examples.length == 0) { throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Example " + "annotated in class {0} is null or empty.", extensionClassFullName)); } else { for (Example example : examples) { //Check if the @Example syntax is empty. if (example.syntax().isEmpty()) { throw new AnnotationValidationException(MessageFormat.format("The @Extension -> " + "@Example -> syntax annotated in class {0} is null or empty.", extensionClassFullName)); } //Check if the @Example description is empty. if (example.description().isEmpty()) { throw new AnnotationValidationException(MessageFormat.format("The @Extension -> " + "@Example -> description annotated in class {0} is null or empty.", extensionClassFullName)); } } } } }
/** * This method uses for validate @Extension / @Example elements. * * @param examples examples array which needs to be validate. * @throws AnnotationValidationException whenever if the validate rule violate, throws the annotation validate * exception with proper message. */ public void examplesValidation(Example[] examples) throws AnnotationValidationException { //Check if the @Example annotated in all the @Extension classes. if (examples.length == 0) { throw new AnnotationValidationException(MessageFormat.format("The @Extension -> @Example " + "annotated in class {0} is null or empty.", extensionClassFullName)); } else { for (Example example : examples) { //Check if the @Example syntax is empty. if (example.syntax().isEmpty()) { throw new AnnotationValidationException(MessageFormat.format("The @Extension -> " + "@Example -> syntax annotated in class {0} is null or empty.", extensionClassFullName)); } //Check if the @Example description is empty. if (example.description().isEmpty()) { throw new AnnotationValidationException(MessageFormat.format("The @Extension -> " + "@Example -> description annotated in class {0} is null or empty.", extensionClassFullName)); } } } } }
for (int i = 0; i < extensionAnnotation.examples().length; i++) { examples[i] = "syntax: " + extensionAnnotation.examples()[i].syntax() + "\n" + "description: " + extensionAnnotation.examples()[i].description();