package com.github.bot.curiosone.core.knowledge;

import java.util.List;

import java.util.Objects;


/**
 * Resumes a semantic query parameters.
 *
 */
public class SemanticQuery {


  private SemanticRelationType relation;

  private String subject;

  private String object;

  private List<String> objAdjectives;

  private String verb;


  /**
   * Constructor.
   * @param relation {@link Relation}
   * @param subject Affirmation subject.
   * @param object Question/affirmation object
   * @param adjectives Object adjectives
   * @param verb Sentence verb.
   */
  public SemanticQuery(SemanticRelationType relation, String subject,String object,
      List<String> adjectives, String verb) {

    this.relation = relation;
    this.subject = subject;
    this.object = object;
    this.objAdjectives = adjectives;
    this.verb = verb;
  }

  public SemanticQuery(SemanticRelationType relation,String subject, String object, String verb) {

    this(relation, subject, object, null, verb);
  }

  public SemanticQuery(SemanticRelationType relation, String object,
      List<String> adjectives, String verb) {

    this(relation, null, object, adjectives, verb);
  }

  public SemanticQuery(SemanticRelationType relation, String object, String verb) {

    this(relation, null, object, null, verb);
  }

  public String getObject() {
    return object;
  }

  public String getSubject() {
    return subject;
  }

  public List<String> getAdjectives() {
    return objAdjectives;
  }

  public SemanticRelationType getRelation() {
    return relation;
  }

  public String getVerb() {
    return verb;
  }

  @Override
  public boolean equals(Object other) {
    if (other == this) {
      return true;
    }
    if (other == null || other.getClass() != this.getClass()) {
      return false;
    }
    SemanticQuery that = (SemanticQuery) other;
    return this.relation.equals(that.relation)
        && this.subject.equals(that.subject)
        && this.object.equals(that.object)
        && this.verb.equals(that.verb);
  }

  @Override
  public int hashCode() {
    return Objects.hash(relation, subject, object, verb);
  }

}

package com.github.bot.curiosone.core.knowledge;

import java.util.List;

import java.util.Objects;

/**
 * Handles interrogations to the SemanticNetwork.
 * Provides methods to create and manage an interrogation.
 */
public class SemanticQuery {

  /**
   * Stores the SemanticRelationType of this interrogation.
   */
  private SemanticRelationType relation;

  /**
   * Stores the subject of this interrogaiton.
   */
  private String subject;

  /**
   * Stores the object of this interrogaiton.
   */
  private String object;

  /**
   * Lists the adjectives of the object of this SemanticQuery.
   */
  private List<String> objAdjectives;

  /**
   * Stores the verb of this verb.
   */
  private String verb;

  /**
   * Constructs this SemanticQuery.
   * @param relation the SemanticRelationType of this SemanticQuery
   * @param subject the subject of this SemanticQuery
   * @param object the object of this SemanticQuery
   * @param adjectives the List of the adjectives of this SemanticQuery
   * @param verb the verb of this SemanticQuery
   */
  public SemanticQuery(SemanticRelationType relation, String subject,String object,
      List<String> adjectives, String verb) {

    this.relation = relation;
    this.subject = subject;
    this.object = object;
    this.objAdjectives = adjectives;
    this.verb = verb;
  }

  /**
   * Constructs this SemanticQuery.
   * @param relation the SemanticRelationType of this SemanticQuery
   * @param subject the subject of this SemanticQuery
   * @param object the object of this SemanticQuery
   * @param verb the verb of this SemanticQuery
   */
  public SemanticQuery(SemanticRelationType relation,String subject, String object, String verb) {

    this(relation, subject, object, null, verb);
  }

  /**
   * Constructs this SemanticQuery.
   * @param relation the SemanticRelationType of this SemanticQuery
   * @param object the object of this SemanticQuery
   * @param adjectives the List of the adjectives of this SemanticQuery
   * @param verb the verb of this SemanticQuery
   */
  public SemanticQuery(SemanticRelationType relation, String object,
      List<String> adjectives, String verb) {

    this(relation, null, object, adjectives, verb);
  }

  /**
   * Constructs this SemanticQuery.
   * @param relation the SemanticRelationType of this SemanticQuery
   * @param object the object of this SemanticQuery
   * @param verb the verb of this SemanticQuery
   */
  public SemanticQuery(SemanticRelationType relation, String object, String verb) {

    this(relation, null, object, null, verb);
  }

  /**
   * Returns the object of this SemanticQuery.
   */
  public String getObject() {
    return object;
  }

  /**
   * Returns the subject of this SemanticQuery.
   */
  public String getSubject() {
    return subject;
  }

  /**
   * Returns a List containing all the adjectives of this SemanticQuery.
   */
  public List<String> getAdjectives() {
    return objAdjectives;
  }

  /**
   * Returns the relation of this SemanticQuery.
   */
  public SemanticRelationType getRelation() {
    return relation;
  }

  /**
   * Returns the verb of this SemanticQuery.
   */
  public String getVerb() {
    return verb;
  }

  /**
   * Checks whether this SemanticQuery equals to the given Object.
   * @param other the other object to be compared against
   * @return {@code true} if this SemanticQuery equals to the given object;
   *         {@code false} otherwise
   */
  @Override
  public boolean equals(Object other) {
    if (other == this) {
      return true;
    }
    if (other == null || other.getClass() != this.getClass()) {
      return false;
    }
    SemanticQuery that = (SemanticQuery) other;
    return this.relation.equals(that.relation)
        && this.subject.equals(that.subject)
        && this.object.equals(that.object)
        && this.verb.equals(that.verb);
  }

  /**
   * Returns the HashCode of this SemanticQuery.
   * The HashCode depends on the relation, subject, object and verb of this SemanticQuery.
   */
  @Override
  public int hashCode() {
    return Objects.hash(relation, subject, object, verb);
  }
}

add SemanticQuery javadoc