Converts annotation entity to DTO.

@param   annotation  The annotation entity.  Cannot be null.

@return  The annotation DTO.

@throws  WebApplicationException  If an error occurs.
337377
public static AnnotationDto transformToDto(Annotation annotation) {
        if (annotation == null) {
            throw new WebApplicationException("Null entity object cannot be converted to Dto object.", Status.INTERNAL_SERVER_ERROR);
        }

        AnnotationDto result = createDtoObject(AnnotationDto.class, annotation);

        return result;
    }
590615
public final String toAnnotationString(Nullability nullability) {
    return nullability == Nullability.EXPLICIT
        ? appendAsNonNull(new StringBuilder(), true).toString()
        : appendTo(new StringBuilder(), true).toString();
  }
540780
public Annotation buildAnnotation(final Class<?> annoClass, final AnnotationInfo info) throws AnnotationReadException {
        
        final Map<String, Object> defaultValues = new HashMap<>();
        for(Method method : annoClass.getMethods()) {
            final Object defaultValue = method.getDefaultValue();
            if(defaultValue != null) {
                defaultValues.put(method.getName(), defaultValue);
            }
        }
        
        final Map<String, Object> xmlValues = new HashMap<>();
        for(String key : info.getAttributeKeys()) {
            try {
                Object value = Ognl.getValue(info.getAttribute(key), ognlContext, new Object());
                xmlValues.put(key, value);
            } catch(OgnlException e) {
                throw new AnnotationReadException(String.format("fail annotation attribute %s with ognl.", key), e);
            }
        }
        
        ClassLoader loader = classLoader;
        if(loader == null){
            loader = Thread.currentThread().getContextClassLoader();
        }
        
        Object obj = Proxy.newProxyInstance(loader, new Class[]{annoClass},
                new InvocationHandler() {
                    @Override
                    public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
                        String name = method.getName();
                        if (name.equals("annotationType")) {
                            return annoClass;
                        } else if(xmlValues.containsKey(name)){
                            return xmlValues.get(name);
                        } else {
                            return defaultValues.get(name);
                        }
                    }
        });
        
        return (Annotation) obj;
    }
225520
public <T extends Annotation> T getAnnotation(Class<T> annotationType) {
        Annotation value = annotations.get(annotationType);
        return annotationType.cast(value);
    }
196211
public static <A extends Annotation> A getAnnotation(Method method, Class<A> annotationClass) {
        A annotation = method.getAnnotation(annotationClass);
        if (annotation == null) {
            for (Annotation metaAnnotation : method.getAnnotations()) {
                annotation = metaAnnotation.annotationType().getAnnotation(annotationClass);
                if (annotation != null) {
                    return annotation;
                }
            }
            Method superclassMethod = getOverriddenMethod(method);
            if (superclassMethod != null) {
                annotation = getAnnotation(superclassMethod, annotationClass);
            }
        }
        return annotation;
    }
362105
public static Map<String, Object> convert(Object pojo,
                                              Class<? extends Annotation> annotationType) {
        return convert(pojo, annotationType, true);
    }
435869
public static <A extends Annotation> A getAnnotation(final Method method, final Class<A> annotationType) {
        A ann = method.getAnnotation(annotationType);
        if (ann == null) {
            for (final Annotation metaAnn : method.getAnnotations()) {
                ann = metaAnn.annotationType().getAnnotation(annotationType);
                if (ann != null) {
                    break;
                }
            }
        }
        return ann;
    }
1331629
public AnnotatedTypeBuilder<X> addToMethod(AnnotatedMethod<? super X> method, Annotation annotation) {
       return addToMethod(method.getJavaMember(), annotation);
   }
420158
public <T> T datastoreToJava(Entity entity) {
		try {
			if (entity == null) {
				return null;
			}
			T result = (T) persistentClass.newInstance();
			populate(entity, result);
			return result;
		} catch (InstantiationException e) {
			throw new RuntimeException(e);
		} catch (IllegalAccessException e) {
			throw new RuntimeException(e);
		}
	}
190498
public AnnotationValidator createAnnotationValidator(ValidateWith validateWithAnnotation) {
        AnnotationValidator validator = VALIDATORS_FOR_ANNOTATION_TYPES.get(validateWithAnnotation);
        if (validator != null) {
            return validator;
        }

        Class<? extends AnnotationValidator> clazz = validateWithAnnotation.value();
        try {
            AnnotationValidator annotationValidator = clazz.newInstance();
            VALIDATORS_FOR_ANNOTATION_TYPES.putIfAbsent(validateWithAnnotation, annotationValidator);
            return VALIDATORS_FOR_ANNOTATION_TYPES.get(validateWithAnnotation);
        } catch (Exception e) {
            throw new RuntimeException("Exception received when creating AnnotationValidator class " + clazz.getName(), e);
        }
    }
981828
public static Object fetchAnnotationElementValue(Annotation annotation, Method element) throws ReflectiveOperationException {
		Object value = element.invoke(annotation);
		if (value == null) {
			String errorMsg = "@" + annotation.annotationType().getName() + "." +
					element.getName() + "() returned null";
			throw new NullPointerException(errorMsg);
		}
		return value;
	}
867240
public <A extends Annotation> A annotation(Class<A> annotationClass) {
        return field.getAnnotation(annotationClass);
    }
871967
public static <A extends Annotation> A getAnnotation(Field field, Class<A> annotationType) {
        if (field == null || annotationType == null) {
            return null;
        }

        return field.getAnnotation(annotationType);
    }
670547
private RequestMapping parseRequestMapping(AnnotationDesc[] annotations) {
		RequestMapping requestMapping = null;
		for (int i = 0; i < annotations.length; i++) {
			if (annotations[i].annotationType().name().equals("RequestMapping")) {
				requestMapping = new RequestMapping();
				setRequestMappingAttrs(requestMapping, annotations[i]);
				break;
			} else if (annotations[i].annotationType().name().equals("PostMapping")
					|| annotations[i].annotationType().name().equals("GetMapping")
					|| annotations[i].annotationType().name().equals("DeleteMapping")
					|| annotations[i].annotationType().name().equals("PutMapping")
					|| annotations[i].annotationType().name().equals("PatchMapping")) {
				requestMapping = new RequestMapping();
				requestMapping.setMethodType(annotations[i].annotationType().name().replace("Mapping","").toUpperCase());
				setRequestMappingAttrs(requestMapping, annotations[i]);
				break;
			}else if(annotations[i].annotationType().name().equals("Path")){
				if(requestMapping == null) {
					requestMapping = new RequestMapping() ;
				}
				for (int j = 0; j < annotations[i].elementValues().length; j++) {
					if ("value".equals(annotations[i].elementValues()[j]
							.element().name())) {
						String url = annotations[i].elementValues()[j].value()
								.toString().replace("\"", "");
						requestMapping.setUrl(url);
					}
				}
				if(requestMapping.getUrl() == null) {
					requestMapping.setUrl("");
				}
			} else if(annotations[i].annotationType().name().equals("GET")
					||annotations[i].annotationType().name().equals("POST")){
				if(requestMapping == null) {
					requestMapping = new RequestMapping() ;
				}
				requestMapping.setMethodType(annotations[i].annotationType().name());
			}
		}
		return requestMapping;
	}
622509
public static JCas getJCas(final Annotation annotation)
    {
        JCas result = null;
        try {
            result = annotation.getCAS().getJCas();
        }
        catch (final CASException e) {
            throw new IllegalArgumentException(e);
        }

        return result;

    }
1082813
@Nullable
  private static <A extends Annotation> A getAnnotation(PropertyDescriptor descriptor,
      Class<A> type) {
    A a = null;
    if (descriptor.getWriteMethod() != null) {
      a = descriptor.getWriteMethod().getAnnotation(type);
    }
    if (a == null && descriptor.getReadMethod() != null) {
      a = descriptor.getReadMethod().getAnnotation(type);
    }
    return a;
  }
1098654
public AnnotatedTypeBuilder<X> addToField(AnnotatedField<? super X> field, Annotation annotation) {
       return addToField(field.getJavaMember(), annotation);
   }