
net.anwiba.spatial.topo.json.v01_0.Geometry Maven / Gradle / Ivy
//Copyright (c) 2017 by Andreas W. Bartels ([email protected])
package net.anwiba.spatial.topo.json.v01_0;
import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import net.anwiba.commons.reflection.ReflectionConstructorInvoker;
public class Geometry {
private final String type = "Geometry";
private Object id = null;
private Properties properties = null;
private final Map _unknownMembers = new LinkedHashMap();
private final static HashMap _classes = new HashMap();
@JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
public static Geometry create(
@JsonProperty("type")
java.lang.String type) {
if (_isNullOrTrimmedEmpty(type)) {
return new Geometry();
}
Class extends Geometry> clazz = _createClass(type);
if (clazz!= null) {
return _createBean(clazz);
}
clazz = _createClass(type.toLowerCase());
if (clazz!= null) {
return _createBean(clazz);
}
java.lang.String className = MessageFormat.format("{0}{1}", type, "Geometry");
clazz = _createClass(className);
if (clazz!= null) {
return _createBean(clazz);
}
className = MessageFormat.format("{0}{1}", type.toLowerCase(), "Geometry");
clazz = _createClass(className);
if (clazz!= null) {
return _createBean(clazz);
}
return new Geometry();
}
private static Geometry _createBean(Class extends Geometry> clazz) {
try {
ReflectionConstructorInvoker invoker = new ReflectionConstructorInvoker(clazz);
return invoker.invoke();
} catch (InvocationTargetException exception) {
throw new RuntimeException(exception);
}
}
private static synchronized Class extends Geometry> _createClass(java.lang.String type) {
if (_classes.containsKey(type)) {
return ((Class extends Geometry> ) _classes.get(type));
}
try {
java.lang.String packageName = Geometry.class.getPackage().getName();
java.lang.String typeName = _setFirstCharacterToUpperCase(type);
java.lang.String className = MessageFormat.format("{0}.{1}", packageName, typeName);
Class> clazz = Class.forName(className);
if (!Geometry.class.isAssignableFrom(clazz)) {
_classes.put(type, null);
return null;
}
_classes.put(type, clazz);
return ((Class extends Geometry> ) clazz);
} catch (ClassNotFoundException exception) {
_classes.put(type, null);
return null;
}
}
private static boolean _isNullOrTrimmedEmpty(java.lang.String value) {
return ((value == null)||value.trim().isEmpty());
}
private static java.lang.String _setFirstCharacterToUpperCase(java.lang.String value) {
if ((value == null)||value.trim().isEmpty()) {
return null;
}
return (value.substring(0, 1).toUpperCase()+ value.substring(1, value.length()));
}
@JsonProperty("type")
public String getType() {
return this.type;
}
@JsonProperty("id")
public void setId(final Object id) {
this.id = id;
}
@JsonProperty("id")
public Object getId() {
return this.id;
}
@JsonProperty("properties")
public void setProperties(final Properties properties) {
this.properties = properties;
}
@JsonProperty("properties")
public Properties getProperties() {
return this.properties;
}
@JsonAnySetter
public void set(final java.lang.String name, final java.lang.Object value) {
Objects.requireNonNull(name);
this._unknownMembers.put(name, value);
}
@JsonAnyGetter
public Map get() {
if (this._unknownMembers.isEmpty()) {
return null;
}
return this._unknownMembers;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy