This commit is contained in:
ramya vasanth 2019-05-15 11:30:24 +05:30
commit 0c7460a2a2
2 changed files with 26 additions and 5 deletions

View File

@ -18,6 +18,10 @@
*/
package org.apache.olingo.commons.api.edm;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* Enumeration of all primitive type kinds.
*/
@ -57,6 +61,26 @@ public enum EdmPrimitiveTypeKind {
GeometryMultiPolygon,
GeometryCollection;
private static Map<String, EdmPrimitiveTypeKind> VALUES_BY_NAME;
static {
Map<String, EdmPrimitiveTypeKind> valuesByName = new HashMap<java.lang.String, EdmPrimitiveTypeKind>();
for (EdmPrimitiveTypeKind value : values()) {
valuesByName.put(value.name(), value);
}
VALUES_BY_NAME = Collections.unmodifiableMap(valuesByName);
}
/**
* Get a type kind by name.
*
* @param name The name.
* @return The type kind or <tt>null</tt> if it does not exist.
*/
public static EdmPrimitiveTypeKind getByName(String name) {
return VALUES_BY_NAME.get(name);
}
/**
* Checks if is a geospatial type.
*

View File

@ -109,11 +109,8 @@ public class EdmTypeInfo {
fullQualifiedName = new FullQualifiedName(namespace, typeName);
try {
primitiveType = EdmPrimitiveTypeKind.valueOf(typeName);
} catch (final IllegalArgumentException e) {
primitiveType = null;
}
primitiveType = EdmPrimitiveTypeKind.getByName(typeName);
if (primitiveType == null && edm != null) {
typeDefinition = edm.getTypeDefinition(fullQualifiedName);
if (typeDefinition == null) {