WordNetCategory.java from Texai at Krugle
Show WordNetCategory.java syntax highlighted
/*
* WordNetCategory.java
*
* Created on November 8, 2006, 8:45 AM
*
* Description: WordNet word category RDF entity.
*
* 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.wordnet.domain.entity;
import java.util.Set;
import javax.persistence.Id;
import net.jcip.annotations.NotThreadSafe;
import org.openrdf.model.URI;
import org.texai.kb.Constants;
import org.texai.kb.persistence.RDFProperty;
import org.texai.kb.persistence.RDFEntity;
import org.texai.kb.persistence.RDFNamespace;
/** WordNet word category RDF entity. This class is not technically thread safe, but client applications should
* treat it as immutable once loaded. The field setter methods should not be used nor should the field
* contents be modified.
*
* @author reed
*/
@RDFEntity(
namespaces={
@RDFNamespace(prefix="texai", namespaceURI=Constants.TEXAI_NAMESPACE),
@RDFNamespace(prefix="cyc", namespaceURI=Constants.CYC_NAMESPACE)},
subject="texai:org.texai.wordnet.domain.entity.WordNetCategory", type="cyc:LinguisticObjectType", context=Constants.TERM_WORDNET21_DOMAIN_CONTEXT)
@NotThreadSafe // but effectively immutable
public class WordNetCategory {
/** the id assigned by the persistence framework */
@Id
private URI id; // NOPMD
/** the category name */
@RDFProperty(predicate="texai:wnCategoryName")
private String name; // NOPMD
/** the set of synsets in this category */
@RDFProperty(predicate="texai:wnCategory", subPropertyOf="cyc:genls", domain="cyc:WordNetSynset", inverse=true)
private Set<WordNetSynset> wnSynsets;
/** Creates a new instance of WordNetCategory */
public WordNetCategory() {
super();
}
/** Creates a new instance of WordNetCategory */
public WordNetCategory(final String name) {
super();
//Preconditions
assert name != null : "name must not be null";
assert name.length() > 0 : "name must not be an empty string";
this.name = name;
}
/** Returns a hash code value for the object.
*
* @return a hash code value for this object.
*/
@Override
public int hashCode() {
return getId().hashCode();
}
/** Determines whether another object is equal to this WordNetSynset.
*
* @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 WordNetCategory)) {
return false;
}
final WordNetCategory that = (WordNetCategory) object;
return this.getId().equals(that.getId());
}
/** Gets the id.
*
* @return the id
*/
public URI getId() {
return id;
}
/** Gets the category name.
*
* @return the category name
*/
public String getName() {
return name;
}
/** Gets the synsets.
*
* @return the synsets
*/
public Set<WordNetSynset> getWNSynsets() {
return wnSynsets;
}
}
See more files for this project here