@Test public void convert() throws Exception { ConversionProperty cp = new ConversionProperty(); annotationHelper.setValueForProperty(cp, "StringProp", "42"); annotationHelper.setValueForProperty(cp, "IntegerProp", "420"); annotationHelper.setValueForProperty(cp, "LongProp", "4200"); annotationHelper.setValueForProperty(cp, "FloatProp", "43"); annotationHelper.setValueForProperty(cp, "DoubleProp", "42.00"); annotationHelper.setValueForProperty(cp, "ByteProp", "1"); Assert.assertEquals("42", cp.stringProp); Assert.assertEquals(Integer.valueOf(420), cp.integerProp); Assert.assertEquals(Long.valueOf("4200"), cp.longProp); Assert.assertEquals(new Float(43), cp.floatProp); Assert.assertEquals(new Double(42.00), cp.doubleProp); Assert.assertEquals(Byte.valueOf("1"), cp.byteProp); }
private Object convert(final Field field, final String propertyValue) { Class<?> fieldClass = field.getType(); try { EdmProperty property = field.getAnnotation(EdmProperty.class); EdmSimpleTypeKind type = mapTypeKind(property.type()); return type.getEdmSimpleTypeInstance().valueOfString(propertyValue, EdmLiteralKind.DEFAULT, null, fieldClass); } catch (EdmSimpleTypeException ex) { throw new AnnotationRuntimeException("Conversion failed for string property [" + propertyValue + "] on field [" + field + "] with error: " + ex.getMessage(), ex); } }
AnnotationHelper { private Object convert(final Field field, final String propertyValue) { Class<?> fieldClass = field.getType(); try { EdmProperty property = field.getAnnotation(EdmProperty.class); EdmSimpleTypeKind type = mapTypeKind(property.type()); return type.getEdmSimpleTypeInstance().valueOfString(propertyValue, EdmLiteralKind.DEFAULT, null, fieldClass); } catch (EdmSimpleTypeException ex) { throw new AnnotationRuntimeException("Conversion failed for string property [" + propertyValue + "] on field [" + field + "] with error: " + ex.getMessage(), ex); } } }
AnnotationHelper { private Object convert(final Field field, final String propertyValue) { Class<?> fieldClass = field.getType(); try { EdmProperty property = field.getAnnotation(EdmProperty.class); EdmSimpleTypeKind type = mapTypeKind(property.type()); return type.getEdmSimpleTypeInstance().valueOfString(propertyValue, EdmLiteralKind.DEFAULT, null, fieldClass); } catch (EdmSimpleTypeException ex) { throw new AnnotationRuntimeException("Conversion failed for string property [" + propertyValue + "] on field [" + field + "] with error: " + ex.getMessage(), ex); } }  }
AnnotationHelper { private Object convert(final Field field, final String propertyValue) { Class<?> fieldClass = field.getType(); try { EdmProperty property = field.getAnnotation(EdmProperty.class); EdmSimpleTypeKind type = mapTypeKind(property.type()); return type.getEdmSimpleTypeInstance().valueOfString(propertyValue, EdmLiteralKind.DEFAULT, null, fieldClass); } catch (EdmSimpleTypeException ex) { throw new AnnotationRuntimeException("Conversion failed for string property [" + propertyValue + "] on field [" + field + "] with error: " + ex.getMessage(), ex); } }  boolean keyMatch(final Object firstInstance, final Object secondInstance); boolean keyMatch(final Object instance, final Map<String, Object> keyName2Value); String extractEntityTypeName(final EdmNavigationProperty enp, final Class<?> fallbackClass); String extractEntityTypeName(final EdmNavigationProperty enp, final Field field); String extractEntityTypeName(final Class<?> annotatedClass); String extractEntitySetName(final Class<?> annotatedClass); FullQualifiedName extractEntityTypeFqn(final EdmEntityType type, final Class<?> annotatedClass); FullQualifiedName extractEntityTypeFqn(final Class<?> annotatedClass); FullQualifiedName extractComplexTypeFqn(final Class<?> annotatedClass); FullQualifiedName extractComplexTypeFqn(final EdmComplexType type, final Class<?> annotatedClass); String extractComplexTypeName(final Class<?> annotatedClass); String generateNamespace(final Class<?> annotatedClass); String getPropertyNameFromAnnotation(final Field field); String getPropertyName(final Field field); String extractToRoleName(final EdmNavigationProperty enp, final Field field); String extractFromRoleEntityName(final Field field); String extractToRoleEntityName(final EdmNavigationProperty enp, final Field field); String getCanonicalRoleName(String name); String extractRelationshipName(final EdmNavigationProperty enp, final Field field); String createCanonicalRelationshipName(String fromRole, String toRole); EdmMultiplicity extractMultiplicity(final EdmNavigationProperty enp, final Field field); T setKeyFields(final T instance, final Map<String, Object> keys); AnnotatedNavInfo getCommonNavigationInfo(final Class<?> sourceClass, final Class<?> targetClass); Class<?> getFieldTypeForProperty(final Class<?> clazz, final String propertyName); Class<?> getFieldTypeForProperty(final Object instance, final String propertyName); Object getValueForProperty(final Object instance, final String propertyName); void setValueForProperty(final Object instance, final String propertyName, final Object propertyValue); Object getValueForField(final Object instance, final String fieldName,
      final Class<? extends Annotation> annotation); Object getValueForField(final Object instance, final Class<? extends Annotation> annotation); Map<String, Object> getValueForAnnotatedFields(final Object instance,
      final Class<? extends Annotation> annotation); void setValueForAnnotatedField(final Object instance, final Class<? extends Annotation> annotation,
      final Object value); void setValuesToAnnotatedFields(final Object instance,
      final Class<? extends Annotation> annotation, final Map<String, Object> fieldName2Value); List<Field> getAnnotatedFields(final Object instance, final Class<? extends Annotation> annotation); List<Field> getAnnotatedFields(final Class<?> fieldClass, final Class<? extends Annotation> annotation); boolean isEdmAnnotated(final Object object); boolean isEdmTypeAnnotated(final Class<?> clazz); boolean isEdmAnnotated(final Class<?> clazz); String getCanonicalName(final Field field); String getCanonicalName(final Class<?> clazz); EdmSimpleTypeKind mapTypeKind(final org.apache.olingo.odata2.api.annotation.edm.EdmType type); EdmMultiplicity mapMultiplicity(final Multiplicity multiplicity); String getCanonicalNamespace(final Class<?> aClass); String extractContainerName(final Class<?> aClass); }
AnnotationHelper { private Object convert(final Field field, final String propertyValue) { Class<?> fieldClass = field.getType(); try { EdmProperty property = field.getAnnotation(EdmProperty.class); EdmSimpleTypeKind type = mapTypeKind(property.type()); return type.getEdmSimpleTypeInstance().valueOfString(propertyValue, EdmLiteralKind.DEFAULT, null, fieldClass); } catch (EdmSimpleTypeException ex) { throw new AnnotationRuntimeException("Conversion failed for string property [" + propertyValue + "] on field [" + field + "] with error: " + ex.getMessage(), ex); } }  boolean keyMatch(final Object firstInstance, final Object secondInstance); boolean keyMatch(final Object instance, final Map<String, Object> keyName2Value); String extractEntityTypeName(final EdmNavigationProperty enp, final Class<?> fallbackClass); String extractEntityTypeName(final EdmNavigationProperty enp, final Field field); String extractEntityTypeName(final Class<?> annotatedClass); String extractEntitySetName(final Class<?> annotatedClass); FullQualifiedName extractEntityTypeFqn(final EdmEntityType type, final Class<?> annotatedClass); FullQualifiedName extractEntityTypeFqn(final Class<?> annotatedClass); FullQualifiedName extractComplexTypeFqn(final Class<?> annotatedClass); FullQualifiedName extractComplexTypeFqn(final EdmComplexType type, final Class<?> annotatedClass); String extractComplexTypeName(final Class<?> annotatedClass); String generateNamespace(final Class<?> annotatedClass); String getPropertyNameFromAnnotation(final Field field); String getPropertyName(final Field field); String extractToRoleName(final EdmNavigationProperty enp, final Field field); String extractFromRoleEntityName(final Field field); String extractToRoleEntityName(final EdmNavigationProperty enp, final Field field); String getCanonicalRoleName(String name); String extractRelationshipName(final EdmNavigationProperty enp, final Field field); String createCanonicalRelationshipName(String fromRole, String toRole); EdmMultiplicity extractMultiplicity(final EdmNavigationProperty enp, final Field field); T setKeyFields(final T instance, final Map<String, Object> keys); AnnotatedNavInfo getCommonNavigationInfo(final Class<?> sourceClass, final Class<?> targetClass); Class<?> getFieldTypeForProperty(final Class<?> clazz, final String propertyName); Class<?> getFieldTypeForProperty(final Object instance, final String propertyName); Object getValueForProperty(final Object instance, final String propertyName); void setValueForProperty(final Object instance, final String propertyName, final Object propertyValue); Object getValueForField(final Object instance, final String fieldName,
      final Class<? extends Annotation> annotation); Object getValueForField(final Object instance, final Class<? extends Annotation> annotation); Map<String, Object> getValueForAnnotatedFields(final Object instance,
      final Class<? extends Annotation> annotation); void setValueForAnnotatedField(final Object instance, final Class<? extends Annotation> annotation,
      final Object value); void setValuesToAnnotatedFields(final Object instance,
      final Class<? extends Annotation> annotation, final Map<String, Object> fieldName2Value); List<Field> getAnnotatedFields(final Object instance, final Class<? extends Annotation> annotation); List<Field> getAnnotatedFields(final Class<?> fieldClass, final Class<? extends Annotation> annotation); boolean isEdmAnnotated(final Object object); boolean isEdmTypeAnnotated(final Class<?> clazz); boolean isEdmAnnotated(final Class<?> clazz); String getCanonicalName(final Field field); String getCanonicalName(final Class<?> clazz); EdmSimpleTypeKind mapTypeKind(final org.apache.olingo.odata2.api.annotation.edm.EdmType type); EdmMultiplicity mapMultiplicity(final Multiplicity multiplicity); String getCanonicalNamespace(final Class<?> aClass); String extractContainerName(final Class<?> aClass); static final String DEFAULT_CONTAINER_NAME; }