QuintaryGAFInfo.java from Texai at Krugle
Show QuintaryGAFInfo.java syntax highlighted
/*
* QuintaryGAFInfo.java
*
* Created on October 24, 2006, 1:58 PM
*
* Description: Contains the specialized fields for QuintaryGAF.
*
* 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 java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Transient;
import org.texai.kb.Constants;
/**
* Entity class QuintaryGAFInfo
*
* @author reed
*/
@Entity
public class QuintaryGAFInfo extends AbstractGAFInfo 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 quintary ground atomic formula */
@OneToOne
private QuintaryGAF quintaryGAF; // NOPMD
/** the predicate
* @serial
*/
@ManyToOne(optional=false, cascade=CascadeType.PERSIST)
private AtomicTerm predicate; // NOPMD
/** the first argument
* @serial
*/
@ManyToOne(optional=false, cascade=CascadeType.PERSIST)
private AbstractTerm arg1; // NOPMD
/** the second argument
* @serial
*/
@ManyToOne(optional=false, cascade=CascadeType.PERSIST)
private AbstractTerm arg2; // NOPMD
/** the third argument
* @serial
*/
@ManyToOne(optional=false, cascade=CascadeType.PERSIST)
private AbstractTerm arg3; // NOPMD
/** the fourth argument
* @serial
*/
@ManyToOne(optional=false, cascade=CascadeType.PERSIST)
private AbstractTerm arg4; // NOPMD
/** the fifth argument
* @serial
*/
@ManyToOne(optional=false, cascade=CascadeType.PERSIST)
private AbstractTerm arg5; // NOPMD
/** Creates a new instance of QuintaryGAFInfo */
public QuintaryGAFInfo() {
super();
}
/**
* Creates a new instance of QuintaryGAFInfo.
*
* @param quintaryGAF the quintary ground atomic formula
* @param predicate the predicate
* @param args the arguments
* @param context the context
* @param strength the assertion strength
* @param generatedPhrase the generated phrase for this ground atomic formula
* @param creator the creator
* @param creationPurpose the creation purpose
* @param creationTimePoint the creation time point
*/
public QuintaryGAFInfo(
final QuintaryGAF quintaryGAF,
final AtomicTerm predicate,
final List<AbstractTerm> args,
final AbstractReifiedTerm context,
final Double strength,
final String generatedPhrase,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose,
final TimePoint creationTimePoint) {
super(
context,
strength,
generatedPhrase,
creator,
creationPurpose,
creationTimePoint);
//Preconditions
assert quintaryGAF != null : "quintaryGAF must not be null";
assert predicate != null : "predicate must not be null";
assert args != null : "args must not be null";
assert args.size() == Constants.QUINTARY_ARGS_SIZE : "quintary GAF must have four arguments " + args.toString();
this.quintaryGAF = quintaryGAF;
this.predicate = predicate;
arg1 = args.get(Constants.ARG1_INDEX);
arg2 = args.get(Constants.ARG2_INDEX);
arg3 = args.get(Constants.ARG3_INDEX);
arg4 = args.get(Constants.ARG4_INDEX);
arg5 = args.get(Constants.ARG5_INDEX);
}
/** Gets the predicate.
*
* @return the predicate
*/
public AtomicTerm getPredicate() {
return predicate;
}
/** Gets the first argument
*
* @return the first argument
*/
public AbstractTerm getArg1() {
return arg1;
}
/** Gets the second argument
*
* @return the second argument
*/
public AbstractTerm getArg2() {
return arg2;
}
/** Gets the third argument
*
* @return the third argument
*/
public AbstractTerm getArg3() {
return arg3;
}
/** Gets the fourth argument
*
* @return the fourth argument
*/
public AbstractTerm getArg4() {
return arg4;
}
/** Gets the fifth argument
*
* @return the fifth argument
*/
public AbstractTerm getArg5() {
return arg5;
}
/** Returns the arguments.
*
* @return the arguments
*/
public List<AbstractTerm> getArgs() {
final List<AbstractTerm> args = new ArrayList<AbstractTerm>(Constants.QUINTARY_ARGS_SIZE);
args.add(arg1);
args.add(arg2);
args.add(arg3);
args.add(arg4);
args.add(arg5);
return args;
}
/** Returns a hash code value for the object.
*
* @return a hash code value for this object
*/
@Override
public int hashCode() {
return getPredicate().hashCode() + getContext().hashCode() + getArgs().hashCode();
}
/**
* Determines whether another object is equal to 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 QuintaryGAFInfo)) {
return false;
}
final QuintaryGAFInfo that = (QuintaryGAFInfo) object;
return this.getPredicate().equals(that.getPredicate())
&& this.getContext().equals(that.getContext())
&& this.getArgs().equals(that.getArgs());
}
/** gets the quintary ground atomic formula
*
* @return the quintary ground atomic formula
*/
public QuintaryGAF getQuintaryGAF() {
return quintaryGAF;
}
}
See more files for this project here