Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) 2013, Francis Galiegue <fgaliegue@gmail.com>
   *
   * This program is free software: you can redistribute it and/or modify
   * it under the terms of the Lesser GNU General Public License as
   * published by the Free Software Foundation, either version 3 of the
   * License, or (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * Lesser GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 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