AtomicTerm.java from Texai at Krugle
Show AtomicTerm.java syntax highlighted
/*
* AtomicTerm.java
*
* Created on October 15, 2006, 10:50 PM
*
* Description: AtomicTerm is an atomic term in the Texai logical representation language.
*
* 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 javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Transient;
import org.texai.kb.Constants;
/**
* Entity class AtomicTerm
*
* @author reed
*/
@Entity
@NamedQueries({
@NamedQuery(name=Constants.QUERY_FIND_ATOMIC_TERM_IDS,
query="SELECT a.termId FROM AtomicTerm a"),
@NamedQuery(name=Constants.QUERY_FIND_ATOMIC_TERM_BY_TERM_NAME,
query="SELECT a FROM AtomicTerm a, AtomicTermInfo ai WHERE ai.termName = :termName AND ai.atomicTerm = a")
})
public class AtomicTerm extends AbstractReifiedTerm {
/**
* 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 atomic term information */
@OneToOne(fetch=FetchType.LAZY, mappedBy = "atomicTerm", cascade=CascadeType.ALL)
private AtomicTermInfo atomicTermInfo; // NOPMD
/** Creates a new instance of AtomicTerm. */
public AtomicTerm() {
super();
}
/** Creates a new instance of AtomicTerm.
*
* @param termName the term name
* @param prettyName the pretty name
* @param uuid the uuid string
* @param creator the creator
* @param creationPurpose the creation purpose
* @param creationTimePoint the creation time point
*/
public AtomicTerm(
final String termName,
final String prettyName,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose,
final TimePoint creationTimePoint) {
this(
termName,
prettyName,
null,
creator,
creationPurpose,
creationTimePoint);
}
/** Creates a new instance of AtomicTerm.
*
* @param termName the term name
* @param prettyName the pretty name
* @param uuid the uuid string
* @param creator the creator
* @param creationPurpose the creation purpose
* @param creationTimePoint the creation time point
*/
public AtomicTerm(
final String termName,
final String prettyName,
final String uuid,
final AbstractReifiedTerm creator,
final AbstractReifiedTerm creationPurpose,
final TimePoint creationTimePoint) {
super();
//Preconditions
assert termName != null : "termName must not be null";
assert termName.length() > 0 : "termName must not be an empty string";
atomicTermInfo = new AtomicTermInfo(
this,
termName,
prettyName,
uuid,
creator,
creationPurpose,
creationTimePoint);
}
/** Sets the term name.
*
* @param termName the term name
*/
public void setTermName(final String termName) {
assert termName != null : "termName must not be null";
assert termName.length() > 0 : "termName must not be an empty string";
atomicTermInfo.setTermName(termName);
}
/** Returns the pretty name.
*
* @return the pretty name
*/
public String getPrettyName() {
return atomicTermInfo.getPrettyName();
}
/** Sets the pretty name.
*
* @param prettyName the pretty name
*/
public void setPrettyName(final String prettyName) {
atomicTermInfo.setPrettyName(prettyName);
}
/** Returns the uuid string.
*
* @return the uuid string
*/
public String getUuid() {
return atomicTermInfo.getUuid();
}
/** Gets the creator.
*
* @return the creator
*/
public AbstractReifiedTerm getCreator() {
return atomicTermInfo.getCreator();
}
/** Gets the creation purpose.
*
* @return the creation purpose
*/
public AbstractReifiedTerm getCreationPurpose() {
return atomicTermInfo.getCreationPurpose();
}
/** Gets the creation date.
*
* @return the creation date
*/
public TimePoint getCreationTimePoint() {
return atomicTermInfo.getCreationTimePoint();
}
/**
* Returns a hash code value for the object. This implementation computes
* a hash code value based on the unchanging termName.
* @return a hash code value for this object
*/
@Override
public int hashCode() {
return getAtomicTermInfo().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 AtomicTerm)) {
return false;
}
final AtomicTerm that = (AtomicTerm) object;
return this.getAtomicTermInfo().equals(that.getAtomicTermInfo());
}
/** Returns a CycL representation of this object.
*
* @return a CycL representation of this object
*/
public String toCycLString() {
return getAtomicTermInfo().toCycLString();
}
/** Returns a string representation of this object.
*
* @return a string representation of this object
*/
@Override
public String toString() {
return getAtomicTermInfo().getTermName();
}
/** Gets the atomic term information.
*
* @return the atomic term information
*/
public AtomicTermInfo getAtomicTermInfo() {
return atomicTermInfo;
}
}
See more files for this project here