
com.relogiclabs.json.schema.internal.tree.PragmaDescriptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of relogiclabs-json-schema Show documentation
Show all versions of relogiclabs-json-schema Show documentation
The New JSON Schema prioritizes simplicity, conciseness, and readability, making
it user-friendly and accessible without the need for extensive prior knowledge.
It offers efficient read-write facilities, precise JSON document definition
through various data types and functions, and extensibility to meet modern web
service diverse requirements.
package com.relogiclabs.json.schema.internal.tree;
import com.relogiclabs.json.schema.type.JBoolean;
import com.relogiclabs.json.schema.type.JNumber;
import com.relogiclabs.json.schema.type.JString;
import lombok.Getter;
import java.util.HashMap;
import java.util.Map;
@Getter
public final class PragmaDescriptor {
public static final String ISO_8601_DATE = "YYYY-MM-DD";
public static final String ISO_8601_TIME = "YYYY-MM-DD'T'hh:mm:ss.FZZ";
private static final Map> PRAGMAS = new HashMap<>();
public static final PragmaDescriptor IGNORE_UNDEFINED_PROPERTIES
= new PragmaDescriptor<>("IgnoreUndefinedProperties", JBoolean.class, false);
public static final PragmaDescriptor FLOATING_POINT_TOLERANCE
= new PragmaDescriptor<>("FloatingPointTolerance", JNumber.class, 1E-10);
public static final PragmaDescriptor IGNORE_OBJECT_PROPERTY_ORDER
= new PragmaDescriptor<>("IgnoreObjectPropertyOrder", JBoolean.class, true);
public static final PragmaDescriptor DATE_DATA_TYPE_FORMAT
= new PragmaDescriptor<>("DateDataTypeFormat", JString.class, ISO_8601_DATE);
public static final PragmaDescriptor TIME_DATA_TYPE_FORMAT
= new PragmaDescriptor<>("TimeDataTypeFormat", JString.class, ISO_8601_TIME);
private final String name;
private final Class> type;
private final T defaultValue;
private PragmaDescriptor(String name, Class> type, T defaultValue) {
this.name = name;
this.type = type;
this.defaultValue = defaultValue;
PRAGMAS.put(name, this);
}
@SuppressWarnings("unchecked")
public static PragmaDescriptor from(String name) {
return (PragmaDescriptor) PRAGMAS.get(name);
}
public boolean matchType(Class> aType) {
return type.isAssignableFrom(aType);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy