public final class URITranslatorConfigurationBuilder extends java.lang.Object implements Thawed<URITranslatorConfiguration>
URITranslatorConfiguration
Example:
final URITranslatorConfiguration cfg
= URITranslatorConfiguration.newBuilder()
.setNamespace("http://my.site/myschemas/")
.addPathRedirect("http://my.site/myschemas/", "resource:/com/foo/myschemas")
.addSchemaRedirect("http://some.other.site/schema.json", "resource:/com/foo/externalsite/schema.json")
.freeze();
When feeding this configuration into a LoadingConfiguration
(using LoadingConfigurationBuilder.setURITranslatorConfiguration(URITranslatorConfiguration)),
the following will take place for URI schema1.json#/definitions/def1:
http://my.site/myschemas/schema1.json#/definitions/def1;SchemaLoader will then be resource:/com/foo/myschemas/schema1.json#/definitions/def1.If URI http://some.other.site/schema.json#bar is encountered,
a schema redirect triggers and will yield URI resource:/com/foo/externalsite/schema.json#bar.
| Modifier and Type | Method and Description |
|---|---|
URITranslatorConfigurationBuilder |
addPathRedirect(java.lang.String from,
java.lang.String to)
Convenience method for adding a path URI redirection
|
URITranslatorConfigurationBuilder |
addPathRedirect(java.net.URI from,
java.net.URI to)
Add a path redirection
|
URITranslatorConfigurationBuilder |
addSchemaRedirect(java.lang.String from,
java.lang.String to)
Convenience method for schema redirections
|
URITranslatorConfigurationBuilder |
addSchemaRedirect(java.net.URI from,
java.net.URI to)
Add a schema redirection
|
URITranslatorConfiguration |
freeze()
Obtain a frozen configuration from this builder
|
URITranslatorConfigurationBuilder |
setNamespace(java.lang.String uri)
Set the namespace for this configuration (convenience method)
|
URITranslatorConfigurationBuilder |
setNamespace(java.net.URI uri)
Set the namespace for this configuration
|
public URITranslatorConfigurationBuilder setNamespace(java.net.URI uri)
All schema loading via URIs (using SchemaLoader.get(URI) or
when encountering a JSON Reference in a schema) will be resolved against
the provided namespace.
uri - the URIjava.lang.NullPointerException - URI is nulljava.lang.IllegalArgumentException - URI is not absolute, or is not a path
URI (ie, does not end with /)public URITranslatorConfigurationBuilder setNamespace(java.lang.String uri)
This calls setNamespace(URI) after creating the URI using
URI.create(String).
uri - the URIjava.lang.NullPointerException - argument is nulljava.lang.IllegalArgumentException - URI.create(String) failedsetNamespace(URI)public URITranslatorConfigurationBuilder addSchemaRedirect(java.net.URI from, java.net.URI to)
Schema redirection occurs after namespace resolution and after path redirection.
from - the URI to redirect fromto - the URI to redirect tojava.lang.NullPointerException - one, or both, argument(s) is/are nulljava.lang.IllegalArgumentException - one, or both, URI(s) are not absolute
JSON References; or a redirection already exists for URI from; or
from and to are the same URI after normalization.public URITranslatorConfigurationBuilder addSchemaRedirect(java.lang.String from, java.lang.String to)
This calls addSchemaRedirect(URI, URI) after converting its
string arguments to URIs using URI.create(String).
from - the URI to redirect fromto - the URI to redirect tojava.lang.NullPointerException - one, or both, argument(s) is/are nulljava.lang.IllegalArgumentException - URI.create(String) failed for
one or both argument(s)public URITranslatorConfigurationBuilder addPathRedirect(java.net.URI from, java.net.URI to)
What is called a "path URI" here is a URI which is absolute,
hierarchical, has no fragment part and whose path component ends with a
/.
from - the "path URI" to redirectto - the target "path URI"java.lang.NullPointerException - one, or both, argument(s) is/are nulljava.lang.IllegalArgumentException - one, or both, argument(s) is/are not
valid path URIs; or a path redirection already exists for from;
or from and to are the same URI after normalization.public URITranslatorConfigurationBuilder addPathRedirect(java.lang.String from, java.lang.String to)
This calls addPathRedirect(URI, URI) after performing URI.create(String) on both arguments.
from - the "path URI" to redirectto - the target "path URI"java.lang.NullPointerException - one, or both, argument(s) is/are nulljava.lang.IllegalArgumentException - URI.create(String) failedaddPathRedirect(URI, URI)public URITranslatorConfiguration freeze()
freeze in interface Thawed<URITranslatorConfiguration>URITranslatorConfiguration