UnaryGAFInfo.java from Texai at Krugle
Show UnaryGAFInfo.java syntax highlighted
/*
* UnaryGAFInfo.java
*
* Created on October 24, 2006, 1:59 PM
*
* Description: Contains the specialized fields for UnaryGAF.
*
* 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 UnaryGAFInfo
*
* @author reed
*/
@Entity
public class UnaryGAFInfo 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 unary ground atomic formula */
@OneToOne
private UnaryGAF unaryGAF; // NOPMD
/** the predicate
* @serial
*/
@ManyToOne(cascade=CascadeType.PERSIST)
private AtomicTerm predicate; // NOPMD
/** the first argument
* @serial
*/
@ManyToOne(cascade=CascadeType.PERSIST)
private AbstractTerm arg1; // NOPMD
/** Creates a new instance of UnaryGAFInfo */
public UnaryGAFInfo() {
super();
}
/**
* Creates a new instance of UnaryGAFInfo.
*
* @param unaryGAF the unary 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 UnaryGAFInfo(
final UnaryGAF unaryGAF,
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 unaryGAF != null : "unaryGAF must not be null";
assert predicate != null : "predicate must not be null";
assert args != null : "args must not be null";
assert args.size() == Constants.UNARY_ARGS_SIZE : "unary GAF must have one argument " + args.toString();
this.unaryGAF = unaryGAF;
this.predicate = predicate;
arg1 = args.get(Constants.ARG1_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;
}
/** Returns the arguments.
*
* @return the arguments
*/
public List<AbstractTerm> getArgs() {
final List<AbstractTerm> args = new ArrayList<AbstractTerm>(Constants.UNARY_ARGS_SIZE);
args.add(arg1);
return args;
}
/** gets the unary ground atomic formula
*
* @return the unary ground atomic formula
*/
public UnaryGAF getUnaryGAF() {
return unaryGAF;
}
/** 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 UnaryGAFInfo)) {
return false;
}
final UnaryGAFInfo that = (UnaryGAFInfo) object;
return this.getPredicate().equals(that.getPredicate())
&& this.getContext().equals(that.getContext())
&& this.getArgs().equals(that.getArgs());
}
}
See more files for this project here