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

hydra.query.Pattern Maven / Gradle / Ivy

There is a newer version: 0.8.0
Show newest version
// Note: this is an automatically generated file. Do not edit.

package hydra.query;

import java.io.Serializable;

/**
 * A query pattern
 */
public abstract class Pattern implements Serializable {
  public static final hydra.core.Name TYPE_NAME = new hydra.core.Name("hydra/query.Pattern");
  
  public static final hydra.core.Name FIELD_NAME_TRIPLE = new hydra.core.Name("triple");
  
  public static final hydra.core.Name FIELD_NAME_NEGATION = new hydra.core.Name("negation");
  
  public static final hydra.core.Name FIELD_NAME_CONJUNCTION = new hydra.core.Name("conjunction");
  
  public static final hydra.core.Name FIELD_NAME_DISJUNCTION = new hydra.core.Name("disjunction");
  
  public static final hydra.core.Name FIELD_NAME_GRAPH = new hydra.core.Name("graph");
  
  private Pattern () {
  
  }
  
  public abstract  R accept(Visitor visitor) ;
  
  public interface Visitor {
    R visit(Triple instance) ;
    
    R visit(Negation instance) ;
    
    R visit(Conjunction instance) ;
    
    R visit(Disjunction instance) ;
    
    R visit(Graph instance) ;
  }
  
  public interface PartialVisitor extends Visitor {
    default R otherwise(Pattern instance) {
      throw new IllegalStateException("Non-exhaustive patterns when matching: " + (instance));
    }
    
    default R visit(Triple instance) {
      return otherwise((instance));
    }
    
    default R visit(Negation instance) {
      return otherwise((instance));
    }
    
    default R visit(Conjunction instance) {
      return otherwise((instance));
    }
    
    default R visit(Disjunction instance) {
      return otherwise((instance));
    }
    
    default R visit(Graph instance) {
      return otherwise((instance));
    }
  }
  
  /**
   * A subject/predicate/object pattern
   */
  public static final class Triple extends hydra.query.Pattern implements Serializable {
    public final hydra.query.TriplePattern value;
    
    public Triple (hydra.query.TriplePattern value) {
      java.util.Objects.requireNonNull((value));
      this.value = value;
    }
    
    @Override
    public boolean equals(Object other) {
      if (!(other instanceof Triple)) {
        return false;
      }
      Triple o = (Triple) (other);
      return value.equals(o.value);
    }
    
    @Override
    public int hashCode() {
      return 2 * value.hashCode();
    }
    
    @Override
    public  R accept(Visitor visitor) {
      return visitor.visit(this);
    }
  }
  
  /**
   * The negation of another pattern
   */
  public static final class Negation extends hydra.query.Pattern implements Serializable {
    public final hydra.query.Pattern value;
    
    public Negation (hydra.query.Pattern value) {
      java.util.Objects.requireNonNull((value));
      this.value = value;
    }
    
    @Override
    public boolean equals(Object other) {
      if (!(other instanceof Negation)) {
        return false;
      }
      Negation o = (Negation) (other);
      return value.equals(o.value);
    }
    
    @Override
    public int hashCode() {
      return 2 * value.hashCode();
    }
    
    @Override
    public  R accept(Visitor visitor) {
      return visitor.visit(this);
    }
  }
  
  /**
   * The conjunction ('and') of several other patterns
   */
  public static final class Conjunction extends hydra.query.Pattern implements Serializable {
    public final java.util.List value;
    
    public Conjunction (java.util.List value) {
      java.util.Objects.requireNonNull((value));
      this.value = value;
    }
    
    @Override
    public boolean equals(Object other) {
      if (!(other instanceof Conjunction)) {
        return false;
      }
      Conjunction o = (Conjunction) (other);
      return value.equals(o.value);
    }
    
    @Override
    public int hashCode() {
      return 2 * value.hashCode();
    }
    
    @Override
    public  R accept(Visitor visitor) {
      return visitor.visit(this);
    }
  }
  
  /**
   * The disjunction (inclusive 'or') of several other patterns
   */
  public static final class Disjunction extends hydra.query.Pattern implements Serializable {
    public final java.util.List value;
    
    public Disjunction (java.util.List value) {
      java.util.Objects.requireNonNull((value));
      this.value = value;
    }
    
    @Override
    public boolean equals(Object other) {
      if (!(other instanceof Disjunction)) {
        return false;
      }
      Disjunction o = (Disjunction) (other);
      return value.equals(o.value);
    }
    
    @Override
    public int hashCode() {
      return 2 * value.hashCode();
    }
    
    @Override
    public  R accept(Visitor visitor) {
      return visitor.visit(this);
    }
  }
  
  /**
   * A pattern which matches within a named subgraph
   */
  public static final class Graph extends hydra.query.Pattern implements Serializable {
    public final hydra.query.GraphPattern value;
    
    public Graph (hydra.query.GraphPattern value) {
      java.util.Objects.requireNonNull((value));
      this.value = value;
    }
    
    @Override
    public boolean equals(Object other) {
      if (!(other instanceof Graph)) {
        return false;
      }
      Graph o = (Graph) (other);
      return value.equals(o.value);
    }
    
    @Override
    public int hashCode() {
      return 2 * value.hashCode();
    }
    
    @Override
    public  R accept(Visitor visitor) {
      return visitor.visit(this);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy