public static final void convertAnnotations(Tree config, Annotation[] annotations)
			throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
		for (Annotation annotation : annotations) {

			// Create entry for annotation
			String annotationName = annotation.toString();
			int i = annotationName.lastIndexOf('.');
			if (i > -1) {
				annotationName = annotationName.substring(i + 1);
			}
			i = annotationName.indexOf('(');
			if (i > -1) {
				annotationName = annotationName.substring(0, i);
			}
			if (annotationName.length() > 1) {
				annotationName = Character.toLowerCase(annotationName.charAt(0)) + annotationName.substring(1);
			} else {
				annotationName = annotationName.toLowerCase();
			}
			if ("name".equals(annotationName) || "override".equals(annotationName)) {
				continue;
			}
			Tree annotationMap = config.putMap(annotationName);

			// Add annotation values
			Class<? extends Annotation> type = annotation.annotationType();
			Method[] members = type.getDeclaredMethods();
			for (Method member : members) {
				member.setAccessible(true);
				String propName = member.getName();
				Object propValue = member.invoke(annotation);
				annotationMap.putObject(propName, propValue);
				Tree newChild = annotationMap.get(propName);
				if (newChild.size() < 1) {
					newChild.remove();
				}
			}
			int size = annotationMap.size();
			if (size == 0) {
				annotationMap.remove();
			} else if (size == 1) {
				Tree value = annotationMap.getFirstChild();
				if (value != null && "value".equals(value.getName())) {
					annotationMap.setObject(value.asObject());
				}
			}
		}
	}
public static final void convertAnnotations ( Tree config , Annotation [ ] annotations ) throws IllegalAccessException , IllegalArgumentException , InvocationTargetException { for ( Annotation annotation : annotations ) { String annotationName = annotation . toString ( ) ; int i = annotationName . lastIndexOf ( '.' ) ; if ( i > - 1 ) { annotationName = annotationName . substring ( i + 1 ) ; } i = annotationName . indexOf ( '(' ) ; if ( i > - 1 ) { annotationName = annotationName . substring ( 0 , i ) ; } if ( annotationName . length ( ) > 1 ) { annotationName = Character . toLowerCase ( annotationName . charAt ( 0 ) ) + annotationName . substring ( 1 ) ; } else { annotationName = annotationName . toLowerCase ( ) ; } if ( "name" . equals ( annotationName ) || "override" . equals ( annotationName ) ) { continue ; } Tree annotationMap = config . putMap ( annotationName ) ; Class < ? extends Annotation > type = annotation . annotationType ( ) ; Method [ ] members = type . getDeclaredMethods ( ) ; for ( Method member : members ) { member . setAccessible ( true ) ; String propName = member . getName ( ) ; Object propValue = member . invoke ( annotation ) ; annotationMap . putObject ( propName , propValue ) ; Tree newChild = annotationMap . get ( propName ) ; if ( newChild . size ( ) < 1 ) { newChild . remove ( ) ; } } int size = annotationMap . size ( ) ; if ( size == 0 ) { annotationMap . remove ( ) ; } else if ( size == 1 ) { Tree value = annotationMap . getFirstChild ( ) ; if ( value != null && "value" . equals ( value . getName ( ) ) ) { annotationMap . setObject ( value . asObject ( ) ) ; } } } }
--- ANNOTATION TO JSON CONVERTER ---