All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xpertss.json.schema.processors.validation.SchemaContextEquivalence Maven / Gradle / Ivy

The newest version!
package xpertss.json.schema.processors.validation;

import xpertss.json.schema.processors.data.SchemaContext;
import com.google.common.base.Equivalence;

/**
 * Equivalence for schema contexts
 *
 * 

This is used by {@link ValidationChain} and {@link ValidationProcessor} to * cache computation results. Two schema contexts are considered equivalent if: *

* *
    *
  • schema trees are considered equivalent,
  • *
  • and the type of the instance is the same.
  • *
* */ public final class SchemaContextEquivalence extends Equivalence { private static final Equivalence INSTANCE = new SchemaContextEquivalence(); public static Equivalence getInstance() { return INSTANCE; } @Override protected boolean doEquivalent(SchemaContext a, SchemaContext b) { return a.getSchema().equals(b.getSchema()) && a.getInstanceType() == b.getInstanceType(); } @Override protected int doHash(SchemaContext t) { return t.getSchema().hashCode() ^ t.getInstanceType().hashCode(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy