Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/olingo-odata4.git
This commit is contained in:
commit
0c7460a2a2
|
@ -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.
|
||||
*
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue