com.hmsinc.epicenter.model.attribute.Gender.java Source code

Java tutorial

Introduction

Here is the source code for com.hmsinc.epicenter.model.attribute.Gender.java

Source

/**
 * Copyright (C) 2008 University of Pittsburgh
 * 
 * 
 * This file is part of Open EpiCenter
 * 
 *     Open EpiCenter 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 3 of the License, or
 *     (at your option) any later version.
 * 
 *     Open EpiCenter 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 Open EpiCenter.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * 
 *   
 */
package com.hmsinc.epicenter.model.attribute;

// Generated Jan 24, 2007 9:56:03 AM by Hibernate Tools 3.2.0.beta8

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.hmsinc.epicenter.model.health.PatientDetail;

/**
 * Gender generated by hbm2java
 */
@Entity
@Table(name = "GENDER")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@XmlRootElement(name = "gender", namespace = "http://epicenter.hmsinc.com/model")
@XmlType(name = "Gender", namespace = "http://epicenter.hmsinc.com/model")
@XmlAccessorType(XmlAccessType.NONE)
@NamedQueries({
        @NamedQuery(name = "getGenderByAbbreviation", query = "from Gender g where g.abbreviation = :abbreviation"),
        @NamedQuery(name = "getUnknownGender", query = "from Gender g where g.abbreviation = 'U'") })
public class Gender extends Attribute implements AttributeObject {

    // Fields

    /**
     * 
     */
    private static final long serialVersionUID = 6466073266319874829L;

    @XmlAttribute(name = "abbreviation", required = true)
    private String abbreviation;

    private Set<PatientDetail> patientDetails = new HashSet<PatientDetail>(0);

    // Constructors

    /** default constructor */
    public Gender() {
        super();
    }

    public Gender(String name, String abbreviation) {
        super(name);
        this.abbreviation = abbreviation;
    }

    /** full constructor */
    public Gender(String name, String abbreviation, Set<PatientDetail> patientDetails) {
        super(name);
        this.abbreviation = abbreviation;
        this.patientDetails = patientDetails;
    }

    @Column(name = "ABBREVIATION", unique = true, nullable = false, insertable = true, updatable = true, length = 1)
    public String getAbbreviation() {
        return this.abbreviation;
    }

    public void setAbbreviation(String abbreviation) {
        this.abbreviation = abbreviation;
    }

    @OneToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "gender")
    public Set<PatientDetail> getPatientDetails() {
        return this.patientDetails;
    }

    public void setPatientDetails(Set<PatientDetail> patientDetails) {
        this.patientDetails = patientDetails;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        return new HashCodeBuilder(13, 9).append(getAbbreviation()).toHashCode();
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object o) {

        boolean ret = false;
        if (o instanceof Gender == false) {
            ret = false;
        } else if (this == o) {
            ret = true;
        } else {
            final Gender ag = (Gender) o;
            ret = new EqualsBuilder().append(getAbbreviation(), ag.getAbbreviation()).isEquals();
        }
        return ret;
    }

    /*
     * (non-Javadoc)
     * 
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        return new ToStringBuilder(this).appendSuper(super.toString()).append("abbreviation", abbreviation)
                .toString();
    }
}