@SuppressWarnings({ "unchecked", "rawtypes" }) private static Enum<?> enumValueToObject(final ClientEnumValue value, final Class<?> reference) { final Namespace namespace = reference.getAnnotation(Namespace.class); final EnumType enumType = reference.getAnnotation(EnumType.class); if (value.getTypeName().equals(namespace.value() + "." + enumType.name())) { return Enum.valueOf((Class<Enum>) reference, value.getValue()); } return null; }
@Override public Map<String, Object> asJavaMap() { final Map<String, Object> result = new LinkedHashMap<String, Object>(); for (Map.Entry<String, ClientProperty> entry : fields.entrySet()) { Object value = null; if (entry.getValue().hasPrimitiveValue()) { value = entry.getValue().getPrimitiveValue().toValue(); } else if (entry.getValue().hasComplexValue()) { value = entry.getValue().getComplexValue().asJavaMap(); } else if (entry.getValue().hasCollectionValue()) { value = entry.getValue().getCollectionValue().asJavaCollection(); } else if (entry.getValue().hasEnumValue()) { value = entry.getValue().getEnumValue().toString(); } result.put(entry.getKey(), value); } return result; }
protected Object getValue(final ClientValue value) { Object valueResource = null; if (value == null) { return null; } if (value.isEnum()) { valueResource = value.asEnum().getValue(); } else if (value.isPrimitive()) { valueResource = value.asPrimitive().toValue(); } else if (value.isComplex()) { List<Property> complexProperties = new ArrayList<Property>(); for (final ClientProperty propertyValue : value.asComplex()) { complexProperties.add(getProperty(propertyValue)); } final ComplexValue lcValueResource = new ComplexValue(); lcValueResource.getValue().addAll(complexProperties); annotations(value.asComplex(), lcValueResource); links(value.asComplex(), lcValueResource); lcValueResource.setTypeName(value.asComplex().getTypeName()); valueResource = lcValueResource; } else if (value.isCollection()) { final ClientCollectionValue<? extends ClientValue> _value = value.asCollection(); ArrayList<Object> lcValueResource = new ArrayList<Object>(); for (final ClientValue collectionValue : _value) { lcValueResource.add(getValue(collectionValue)); } valueResource = lcValueResource; } return valueResource; }
propertyValue); } else if (odataValuable.hasEnumValue()) { propertyResource.setType(odataValuable.getEnumValue().getTypeName()); propertyResource.setValue(ValueType.ENUM, propertyValue); } else if (odataValuable.hasComplexValue()) {
protected Object getValue(final ClientValue value) { Object valueResource = null; if (value == null) { return null; } if (value.isEnum()) { valueResource = value.asEnum().getValue(); } else if (value.isPrimitive()) { valueResource = value.asPrimitive().toValue(); } else if (value.isComplex()) { List<Property> complexProperties = new ArrayList<Property>(); for (final ClientProperty propertyValue : value.asComplex()) { complexProperties.add(getProperty(propertyValue)); } final ComplexValue lcValueResource = new ComplexValue(); lcValueResource.getValue().addAll(complexProperties); annotations(value.asComplex(), lcValueResource); links(value.asComplex(), lcValueResource); lcValueResource.setTypeName(value.asComplex().getTypeName()); valueResource = lcValueResource; } else if (value.isCollection()) { final ClientCollectionValue<? extends ClientValue> _value = value.asCollection(); ArrayList<Object> lcValueResource = new ArrayList<Object>(); for (final ClientValue collectionValue : _value) { lcValueResource.add(getValue(collectionValue)); } valueResource = lcValueResource; } return valueResource; }
propertyValue); } else if (odataValuable.hasEnumValue()) { propertyResource.setType(odataValuable.getEnumValue().getTypeName()); propertyResource.setValue(ValueType.ENUM, propertyValue); } else if (odataValuable.hasComplexValue()) {
@SuppressWarnings({ "unchecked", "rawtypes" }) private static Enum<?> enumValueToObject(final ClientEnumValue value, final Class<?> reference) { final Namespace namespace = reference.getAnnotation(Namespace.class); final EnumType enumType = reference.getAnnotation(EnumType.class); if (value.getTypeName().equals(namespace.value() + "." + enumType.name())) { return Enum.valueOf((Class<Enum>) reference, value.getValue()); } return null; }
@Override public Map<String, Object> asJavaMap() { final Map<String, Object> result = new LinkedHashMap<String, Object>(); for (Map.Entry<String, ClientProperty> entry : fields.entrySet()) { Object value = null; if (entry.getValue().hasPrimitiveValue()) { value = entry.getValue().getPrimitiveValue().toValue(); } else if (entry.getValue().hasComplexValue()) { value = entry.getValue().getComplexValue().asJavaMap(); } else if (entry.getValue().hasCollectionValue()) { value = entry.getValue().getCollectionValue().asJavaCollection(); } else if (entry.getValue().hasEnumValue()) { value = entry.getValue().getEnumValue().toString(); } result.put(entry.getKey(), value); } return result; }
value = param.getValue().asCollection().asJavaCollection(); } else if (param.getValue().isEnum()) { value = param.getValue().asEnum().toString();
value = param.getValue().asCollection().asJavaCollection(); } else if (param.getValue().isEnum()) { value = param.getValue().asEnum().toString();
@Override public Collection<Object> asJavaCollection() { final List<Object> result = new ArrayList<Object>(); for (ClientValue value : values) { if (value.isPrimitive()) { result.add(value.asPrimitive().toValue()); } else if (value.isComplex()) { result.add(value.asComplex().asJavaMap()); } else if (value.isCollection()) { result.add(value.asCollection().asJavaCollection()); } else if (value.isEnum()) { result.add(value.asEnum().toString()); } } return result; }
@Override public Collection<Object> asJavaCollection() { final List<Object> result = new ArrayList<Object>(); for (ClientValue value : values) { if (value.isPrimitive()) { result.add(value.asPrimitive().toValue()); } else if (value.isComplex()) { result.add(value.asComplex().asJavaMap()); } else if (value.isCollection()) { result.add(value.asCollection().asJavaCollection()); } else if (value.isEnum()) { result.add(value.asEnum().toString()); } } return result; }