Show Friend.java syntax highlighted
/*
* Friend.java
*
* Created on December 19, 2006, 4:19 PM
*
* Description: Extends the FOAF ontology to represent a friend.
*
* 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.persistence.sample;
import java.util.Date;
import java.util.Set;
import org.texai.kb.Constants;
import org.texai.kb.persistence.RDFEntity;
import org.texai.kb.persistence.RDFNamespace;
import org.texai.kb.persistence.RDFProperty;
/** Extends the FOAF ontology to represent a friend.
*
* @author reed
*/
@RDFEntity(
namespaces={
@RDFNamespace(prefix="texai", namespaceURI=Constants.TEXAI_NAMESPACE),
@RDFNamespace(prefix="foaf", namespaceURI=Constants.FOAF_NAMESPACE)},
subject="texai:Friend", subClassOf="foaf:Person", context="texai:FriendContext")
// RDF entity classes must not have the final modifier.
public class Friend extends Person {
/** extends the FOAF ontology to provide date of birth */
@RDFProperty(predicate="texai:dateOfBirth", subPropertyOf="texai:hasAttribute", range="foaf:Person")
private Date dateOfBirth;
/**
* Creates a new Friend instance. RDF entities are required to have
* a no-parameter constructor among their constructors.
*/
public Friend() {
}
/** Creates a new Friend instance. RDF entities are required to have
* a no-parameter constructor among their constructors.
*/
public Friend(
final String name,
final String birthday,
final String gender,
final Set<Object> thingsMade,
final String firstName,
final String familyName,
final Date dateOfBirth) {
setName(name);
setBirthday(birthday);
setGender(gender);
setThingsMade(thingsMade);
setFirstName(firstName);
setFamilyName(familyName);
setDateOfBirth(dateOfBirth);
}
/** Returns a string representation of this object.
*
* @return a string representation of this object
*/
public String toString() {
return "[friend: " + getName() + "]";
}
public Date getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(final Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
/** Returns whether the given object is equal to this object.
*
* @param obj the given object
* @return whether the given object is equal to this object
*/
@Override
public boolean equals(final Object obj) {
if (obj instanceof Friend) {
final Friend that = (Friend) obj;
return this.getAgentId().equals(that.getAgentId());
} else {
return false;
}
}
/** Returns a hash code for this object.
*
* @return a hash code for this object
*/
@Override
public int hashCode() {
if (getAgentId() == null) {
return super.hashCode();
} else {
return getAgentId().hashCode();
}
}
}
See more files for this project here