Code Search for Developers
 
 
  

FormulaArgument.java from Texai at Krugle


Show FormulaArgument.java syntax highlighted

/*
 * FormulaArgument.java
 *
 * Created on October 24, 2006, 12:22 PM
 *
 * Description: Contains a formula argument and position.  In the formula FruitFn(AppleTree), there are
 * two arguments: argIndex 0 has the term FruitFn and argIndex 1 has the term AppleTree.
 *
 * Copyright (C) 2006 Stephen L. Reed.
 *
 * This program is free software; you can redistribute it and/or modify it under the terms
 * of the GNU General Public License as published by the Free Software Foundation; either
 * version 2 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 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

package org.texai.kb.ejb.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Transient;

/**
 * Entity class FormulaArgument
 *
 *
 * @author reed
 */
@Entity
public class FormulaArgument implements Serializable {


  /**
   * Determines if a de-serialized file is compatible with this class.
   *
   * Maintainers must change this value if and only if the new version
   * of this class is not compatible with old versions. See Sun docs
   * for <a href=http://java.sun.com/products/jdk/1.1/docs/guide
   * /serialization/spec/version.doc.html> details. </a>
   *
   * Not necessary to include in first version of the class, but
   * included here as a reminder of its importance.
   */
  @Transient
  private static final long serialVersionUID = 1L;

  /** the id */
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private Long formulaArgumentId;         // NOPMD

  /** the formula info for which this term is an argument */
  @ManyToOne
  private FormulaInfo formulaInfo;            // NOPMD

  /**
   * the argIndex of this formula argument
   */
  @Basic
  private int argIndex;                   // NOPMD

  /** the formula argument term */
  @ManyToOne(cascade={CascadeType.PERSIST})
  private AbstractTerm arg;               // NOPMD

  /** Creates a new instance of FormulaArgument. */
  public FormulaArgument() {
    super();
  }

  /**
   * Creates a new instance of FormulaArgument.
   * 
   * @param formulaInfo the formula info for which this term is an argument
   * @param argIndex the index of this formula argument
   * @param arg the formula argument term
   */
  public FormulaArgument(final FormulaInfo formulaInfo, final int argIndex, final AbstractTerm arg) {
    super();
    //Preconditions
    assert formulaInfo != null : "formulaInfo must not be null";
    assert argIndex >= 0 : "argIndex must not be negative";
    assert arg != null : "arg must not be null";

    this.formulaInfo = formulaInfo;
    this.argIndex = argIndex;
    this.arg = arg;
  }

  /**
   * Gets the formulaArgumentId of this FormulaArgument.
   *
   * @return the iformulaArgumentId
   */
  public Long getId() {
    return this.formulaArgumentId;
  }

  /**
   * Sets the formulaArgumentId of this FormulaArgument to the specified value.
   *
   * @param formulaArgumentId new id
   */
  public void setId(final Long formulaArgumentId) {
    this.formulaArgumentId = formulaArgumentId;
  }

  /** Gets the formula info for which this term is an argument.
   *
   * @return the formula info for which this term is an argument
   */
  public FormulaInfo getFormulaInfo() {
    return formulaInfo;
  }

  /**
   * Gets the argument index of this formula argument.
   * 
   * @return the argument index of this formula argument
   */
  public int getArgIndex() {
    return argIndex;
  }

  /** Gets the formula argument term.
   *
   * @return the formula argument term
   */
  public AbstractTerm getArg() {
    return arg;
  }

  /** Returns a hash code value for the object.
   *
   * @return a hash code value for this object.
   */
  @Override
  public int hashCode() {
    return arg.hashCode();
  }

  /**
   * Determines whether another object is equal to this FormulaArgument.  The result is
   * <code>true</code> if and only if the argument is not null and is a FormulaArgument object that
   * has the same formulaArgumentId field values as this object.
   *
   * @param object the reference object with which to compare
   * @return <code>true</code> if this object is the same as the argument;
   * <code>false</code> otherwise.
   */
  @Override
  public boolean equals(final Object object) {
    if (!(object instanceof FormulaArgument)) {
      return false;
    }
    final FormulaArgument that = (FormulaArgument) object;
    return this.argIndex == that.argIndex && this.arg.equals(that.arg);
  }

  /**
   * Returns a string representation of the object.  This implementation constructs
   * that representation based on the formulaArgumentId fields.
   *
   * @return a string representation of the object.
   */
  @Override
  public String toString() {
    return "[" + argIndex + ": " + arg.toString() +"]";
  }

}




See more files for this project here

Texai

Texai is an chatbot that intelligently seeks to acquire knowledge and friendly behaviors.

Project homepage: http://sourceforge.net/projects/texai
Programming language(s): Java,Shell Script,XML
License: other

  AbstractGAF.java
  AbstractGAFInfo.java
  AbstractReifiedTerm.java
  AbstractTerm.java
  AtomicTerm.java
  AtomicTermInfo.java
  BinaryGAF.java
  BinaryGAFInfo.java
  Formula.java
  FormulaArgument.java
  FormulaInfo.java
  NonAtomicTerm.java
  NonAtomicTermInfo.java
  PBlob.java
  PBlobInfo.java
  PCharacter.java
  PCharacterInfo.java
  PClob.java
  PClobInfo.java
  PDate.java
  PDateInfo.java
  PDouble.java
  PDoubleInfo.java
  PLong.java
  PLongInfo.java
  PString.java
  PStringInfo.java
  PVariable.java
  PVariableInfo.java
  QuaternaryGAF.java
  QuaternaryGAFInfo.java
  QuintaryGAF.java
  QuintaryGAFInfo.java
  Rule.java
  RuleInfo.java
  Symbol.java
  SymbolInfo.java
  TernaryGAF.java
  TernaryGAFInfo.java
  TimePoint.java
  TimePointInfo.java
  UnaryGAF.java
  UnaryGAFInfo.java
  package.html