Package org.apache.juneau.dto.jsonschema
Class JsonSchemaMap
java.lang.Object
java.util.AbstractMap<K,V>
java.util.concurrent.ConcurrentHashMap<URI,JsonSchema>
org.apache.juneau.dto.jsonschema.JsonSchemaMap
- All Implemented Interfaces:
Serializable
,ConcurrentMap<URI,
,JsonSchema> Map<URI,
JsonSchema>
A container for retrieving JSON
JsonSchema
objects by URI.
Subclasses must implement one of the following methods to load schemas from external sources:
-
getReader(URI)
- If schemas should be loaded from readers and automatically parsed. -
load(URI)
- If you want control over construction ofJsonSchema
objects.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.ConcurrentHashMap
ConcurrentHashMap.KeySetView<K extends Object,
V extends Object> Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,
V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object, V extends Object> -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionadd
(JsonSchema... schemas) Convenience method for pre-populating this map with the specified schemas.Return theJsonSchema
object at the specified URI.Subclasses must implement either this method orload(URI)
to load the schema with the specified URI.Subclasses must implement either this method orgetReader(URI)
to load the schema with the specified URI.Methods inherited from class java.util.concurrent.ConcurrentHashMap
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, getOrDefault, hashCode, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, put, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, values
Methods inherited from class java.util.AbstractMap
clone
-
Constructor Details
-
JsonSchemaMap
public JsonSchemaMap()
-
-
Method Details
-
get
Return theJsonSchema
object at the specified URI.If this schema object has not been loaded yet, calls
load(URI)
.The value can be of any of the following types:
URI
,URL
,String
. Strings must be valid URIs.URIs defined by
UriResolver
can be used for values.- Specified by:
get
in interfaceMap<URI,
JsonSchema> - Overrides:
get
in classConcurrentHashMap<URI,
JsonSchema> - Parameters:
uri
- The URI of the schema to retrieve.- Returns:
- The JsonSchema, or
null if schema was not located and could not be loaded.
-
add
Convenience method for pre-populating this map with the specified schemas.The schemas passed in through this method MUST have their ID properties set.
- Parameters:
schemas
- The set of schemas to add to this map.- Returns:
- This object.
- Throws:
RuntimeException
- If one or more schema objects did not have their ID property set.
-
load
Subclasses must implement either this method orgetReader(URI)
to load the schema with the specified URI.It's up to the implementer to decide where these come from.
The default implementation calls
getReader(URI)
and parses the schema document. IfgetReader(URI)
returnsnull , this method returnsnull indicating this is an unreachable document.- Parameters:
uri
- The URI to load the schema from.- Returns:
- The parsed schema.
-
getReader
Subclasses must implement either this method orload(URI)
to load the schema with the specified URI.It's up to the implementer to decide where these come from.
The default implementation returns
null .- Parameters:
uri
- The URI to connect to and retrieve the contents.- Returns:
- The reader from reading the specified URI.
-