/** * This will create a synthetic annotation using the provided * interface. All attributes for the provided annotation will * have their default values. * * @param loader this is the class loader to load the annotation * @param label this is the annotation interface to be used * @param attribute determines if a map has an attribute key * * @return this returns the synthetic annotation to be used */ private Annotation getInstance(ClassLoader loader, Class label, boolean attribute) throws Exception { AnnotationHandler handler = new AnnotationHandler(label, required, attribute); Class[] list = new Class[] {label}; return (Annotation) Proxy.newProxyInstance(loader, list, handler); }
/** * This is used to build a string from the annotation. The string * produces adheres to the typical string representation of a * normal annotation. This ensures that an exceptions that are * thrown with a string representation of the annotation are * identical to those thrown with a normal annotation. * * @return returns a string representation of the annotation */ public String toString() { StringBuilder builder = new StringBuilder(); if(type != null) { name(builder); attributes(builder); } return builder.toString(); }
/** * This is used to build a string from the annotation. The string * produces adheres to the typical string representation of a * normal annotation. This ensures that an exceptions that are * thrown with a string representation of the annotation are * identical to those thrown with a normal annotation. * * @param builder this is the builder used to compose the text */ private void attributes(StringBuilder builder) { Method[] list = type.getDeclaredMethods(); for(int i = 0; i < list.length; i++) { String attribute = list[i].getName(); Object value = value(list[i]); if(i > 0) { builder.append(','); builder.append(' '); } builder.append(attribute); builder.append('='); builder.append(value); } builder.append(')'); }
/** * This is used to build a string from the annotation. The string * produces adheres to the typical string representation of a * normal annotation. This ensures that an exceptions that are * thrown with a string representation of the annotation are * identical to those thrown with a normal annotation. * * @param builder this is the builder used to compose the text */ private void attributes(StringBuilder builder) { Method[] list = type.getDeclaredMethods(); for(int i = 0; i < list.length; i++) { String attribute = list[i].getName(); Object value = value(list[i]); if(i > 0) { builder.append(','); builder.append(' '); } builder.append(attribute); builder.append('='); builder.append(value); } builder.append(')'); }
/** * This is used to build a string from the annotation. The string * produces adheres to the typical string representation of a * normal annotation. This ensures that an exceptions that are * thrown with a string representation of the annotation are * identical to those thrown with a normal annotation. * * @return returns a string representation of the annotation */ public String toString() { StringBuilder builder = new StringBuilder(); if(type != null) { name(builder); attributes(builder); } return builder.toString(); }
/** * This will create a synthetic annotation using the provided * interface. All attributes for the provided annotation will * have their default values. * * @param loader this is the class loader to load the annotation * @param label this is the annotation interface to be used * @param attribute determines if a map has an attribute key * * @return this returns the synthetic annotation to be used */ private Annotation getInstance(ClassLoader loader, Class label, boolean attribute) throws Exception { AnnotationHandler handler = new AnnotationHandler(label, required, attribute); Class[] list = new Class[] {label}; return (Annotation) Proxy.newProxyInstance(loader, list, handler); }
/** * This is used to build a string from the annotation. The string * produces adheres to the typical string representation of a * normal annotation. This ensures that an exceptions that are * thrown with a string representation of the annotation are * identical to those thrown with a normal annotation. * * @param builder this is the builder used to compose the text */ private void attributes(StringBuilder builder) { Method[] list = type.getDeclaredMethods(); for(int i = 0; i < list.length; i++) { String attribute = list[i].getName(); Object value = value(list[i]); if(i > 0) { builder.append(','); builder.append(' '); } builder.append(attribute); builder.append('='); builder.append(value); } builder.append(')'); }
/** * This is used to build a string from the annotation. The string * produces adheres to the typical string representation of a * normal annotation. This ensures that an exceptions that are * thrown with a string representation of the annotation are * identical to those thrown with a normal annotation. * * @return returns a string representation of the annotation */ public String toString() { StringBuilder builder = new StringBuilder(); if(type != null) { name(builder); attributes(builder); } return builder.toString(); }
/** * This will create a synthetic annotation using the provided * interface. All attributes for the provided annotation will * have their default values. * * @param loader this is the class loader to load the annotation * @param label this is the annotation interface to be used * @param attribute determines if a map has an attribute key * * @return this returns the synthetic annotation to be used */ private Annotation getInstance(ClassLoader loader, Class label, boolean attribute) throws Exception { AnnotationHandler handler = new AnnotationHandler(label, required, attribute); Class[] list = new Class[] {label}; return (Annotation) Proxy.newProxyInstance(loader, list, handler); }