Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.github.fge.jsonschema.cfg;
  
 
 import java.net.URI;
 import java.util.Map;
 
 import static com.github.fge.jsonschema.messages.ConfigurationMessages.*;
 
 public final class LoadingConfigurationBuilder
     implements Thawed<LoadingConfiguration>
 {
     private static final URI EMPTY_NAMESPACE = URI.create("#");
 
     URI namespace;
     final Map<URIURIschemaRedirects;
     final Map<URIJsonNodepreloadedSchemas;
 
     {
          = DefaultDownloadersDictionary.get().thaw();
          = ;
          = .;
          = Maps.newHashMap();
          = Maps.newHashMap();
         for (final SchemaVersion version: SchemaVersion.values())
             .put(version.getLocation(), version.getSchema());
     }
 
     {
          = cfg.downloaders.thaw();
          = cfg.namespace;
          = cfg.dereferencing;
          = Maps.newHashMap(cfg.schemaRedirects);
          = Maps.newHashMap(cfg.preloadedSchemas);
     }
 
     public LoadingConfigurationBuilder addScheme(final String scheme,
         final URIDownloader downloader)
     {
         .addEntry(checkScheme(scheme), downloader);
         return this;
     }
 
     public LoadingConfigurationBuilder removeScheme(final String scheme)
     {
         /*
          * No checks for null or anything there: adding entries will have been
          * filtered out anyway, so no harm.
          */
         .removeEntry(scheme);
         return this;
     }
 
     public LoadingConfigurationBuilder setNamespace(final String input)
     {
          = RefSanityChecks.absoluteLocator(input);
         return this;
     }
 
         final Dereferencing dereferencing)
     {
         this. = dereferencing;
         return this;
     }
 
     public LoadingConfigurationBuilder addSchemaRedirect(final String source,
         final String destination)
     {
         final URI sourceURI = RefSanityChecks.absoluteLocator(source);
         final URI destinationURI = RefSanityChecks.absoluteLocator(destination);
         .put(sourceURIdestinationURI);
         if (sourceURI.equals(destinationURI))
             throw new LoadingConfigurationError(new ProcessingMessage()
                 .message().put("uri"sourceURI));
         return this;
     }
 
     public LoadingConfigurationBuilder preloadSchema(final String input,
         final JsonNode node)
     {
         final ProcessingMessage message = new ProcessingMessage();
 
         if (node == null)
             throw new LoadingConfigurationError(message.message());
        final URI key = RefSanityChecks.absoluteLocator(input);
        if (.containsKey(key))
            throw new LoadingConfigurationError(message.message()
                .put("uri"key));
        .put(keynode);
        return this;
    }
    public LoadingConfigurationBuilder preloadSchema(final JsonNode schema)
    {
        final JsonNode node = schema.path("id");
        if (!node.isTextual())
            throw new LoadingConfigurationError(new ProcessingMessage()
                .message());
        return preloadSchema(node.textValue(), schema);
    }
    @Override
    public LoadingConfiguration freeze()
    {
        return new LoadingConfiguration(this);
    }
    private static String checkScheme(final String scheme)
    {
        final ProcessingMessage message = new ProcessingMessage();
        if (scheme == null)
            throw new LoadingConfigurationError(message.message());
        if (scheme.isEmpty())
            throw new LoadingConfigurationError(message.message());
        try {
            new URI(scheme"x""y");
        } catch (URISyntaxException ignored) {
            throw new LoadingConfigurationError(message.message()
                .put("scheme"scheme));
        }
        return scheme;
    }
New to GrepCode? Check out our FAQ X