Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) 2014, Francis Galiegue (fgaliegue@gmail.com)
   *
   * This software is dual-licensed under:
   *
   * - the Lesser General Public License (LGPL) version 3.0 or, at your option, any
   *   later version;
   * - the Apache Software License (ASL) version 2.0.
   *
  * The text of this file and of both licenses is available at the root of this
  * project or, if you have the jar distribution, in directory META-INF/, under
  * the names LGPL-3.0.txt and ASL-2.0.txt respectively.
  *
  * Direct link to the sources:
  *
  * - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
  * - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
  */
 
 package com.github.fge.jsonschema.processors.digest;
 
 
 import java.util.Map;

The schema digester

This processor is called by a com.github.fge.jsonschema.processors.validation.ValidationChain after it has made sure that the schema is syntactically valid.

 
 public final class SchemaDigester
     implements Processor<SchemaContextSchemaDigest>
 {
     private final ListMultimap<NodeTypeStringtypeMap
         = ArrayListMultimap.create();
     private final Map<StringDigesterdigesterMap = Maps.newHashMap();
 
     public SchemaDigester(final Library library)
     {
         this(library.getDigesters());
     }
 
     public SchemaDigester(final Dictionary<Digesterdict)
     {
         String keyword;
         Digester digester;
 
         final Map<StringDigestermap = dict.entries();
 
         for (final Map.Entry<StringDigesterentrymap.entrySet()) {
             keyword = entry.getKey();
             digester = entry.getValue();
             .put(keyworddigester);
             for (final NodeType typedigester.supportedTypes())
                 .put(typekeyword);
         }
     }
 
     @Override
     public SchemaDigest process(final ProcessingReport report,
         final SchemaContext input)
         throws ProcessingException
     {
         final JsonNode schema = input.getSchema().getNode();
         final NodeType type = input.getInstanceType();
         final Map<StringJsonNodemap = Maps.newHashMap(buildDigests(schema));
         map.keySet().retainAll(.get(type));
         return new SchemaDigest(inputmap);
     }
 
     private Map<StringJsonNodebuildDigests(final JsonNode schema)
     {
         final ImmutableMap.Builder<StringJsonNodebuilder
             = ImmutableMap.builder();
         final Map<StringDigestermap = Maps.newHashMap();
 
         map.keySet().retainAll(Sets.newHashSet(schema.fieldNames()));
 
         for (final Map.Entry<StringDigesterentrymap.entrySet())
             builder.put(entry.getKey(), entry.getValue().digest(schema));
 
         return builder.build();
     }
    @Override
    public String toString()
    {
        return "schema digester";
    }
New to GrepCode? Check out our FAQ X