Save This Page
Home » jdo2-tck-2.3-ea-src » org.apache.jdo.tck.pc.companyAnnotatedJPA » [javadoc | source]
    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    * 
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    * 
   11    * Unless required by applicable law or agreed to in writing, software 
   12    * distributed under the License is distributed on an "AS IS" BASIS, 
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
   14    * See the License for the specific language governing permissions and 
   15    * limitations under the License.
   16    */
   17    
   18   package org.apache.jdo.tck.pc.companyAnnotatedJPA;
   19   
   20   import javax.persistence;
   21   
   22   import java.util.Date;
   23   
   24   import org.apache.jdo.tck.pc.company.IPartTimeEmployee;
   25   import org.apache.jdo.tck.util.DeepEquality;
   26   import org.apache.jdo.tck.util.EqualityHelper;
   27   
   28   /**
   29    * This class represents a part-time employee.
   30    */
   31   @Entity
   32   public class JPAAppPartTimeEmployee extends JPAAppEmployee 
   33           implements IPartTimeEmployee {
   34   
   35       @Column(name="WAGE")
   36       private double wage;
   37   
   38       /** This is the JDO-required no-args constructor. The TCK relies on
   39        * this constructor for testing PersistenceManager.newInstance(PCClass).
   40        */
   41       public JPAAppPartTimeEmployee() {}
   42   
   43       /**
   44        * Construct a part-time employee.
   45        * @param personid The identifier for the person.
   46        * @param first The person's first name.
   47        * @param last The person's last name.
   48        * @param middle The person's middle name.
   49        * @param born The person's birthdate.
   50        * @param hired The date the person was hired.
   51        * @param wage The person's wage.
   52        */
   53       public JPAAppPartTimeEmployee(long personid, String first, String last,
   54                               String middle, Date born,
   55                               Date hired, double wage ) {
   56           super(personid, first, last, middle, born, hired);
   57           this.wage = wage;
   58       }
   59   
   60       /**
   61        * Construct a part-time employee.
   62        * @param personid The identifier for the person.
   63        * @param first The person's first name.
   64        * @param last The person's last name.
   65        * @param middle The person's middle name.
   66        * @param born The person's birthdate.
   67        * @param addr The person's address.
   68        * @param hired The date the person was hired.
   69        * @param wage The person's wage.
   70        */
   71       public JPAAppPartTimeEmployee(long personid, String first, String last,
   72                               String middle, Date born, JPAAppAddress addr, 
   73                               Date hired, double wage ) {
   74           super(personid, first, last, middle, born, addr, hired);
   75           this.wage = wage;
   76       }
   77   
   78       /**
   79        * Get the wage of the part-time employee.
   80        * @return The wage of the part-time employee.
   81        */
   82       public double getWage() {
   83           return wage;
   84       }
   85   
   86       /**
   87        * Set the wage of the part-time employee.
   88        * @param wage The wage of the part-time employee.
   89        */
   90       public void setWage(double wage) {
   91           this.wage = wage;
   92       }
   93   
   94       /**
   95        * Returns a String representation of a <code>JPAAppPartTimeEmployee</code> object.
   96        * 
   97        * 
   98        * @return a String representation of a <code>JPAAppPartTimeEmployee</code> object.
   99        */
  100       public String toString() {
  101           return "JPAPartTimeEmployee(" + getFieldRepr() + ")";
  102       }
  103   
  104       /**
  105        * Returns a String representation of the non-relationship fields.
  106        * @return a String representation of the non-relationship fields.
  107        */
  108       public String getFieldRepr() {
  109           StringBuffer rc = new StringBuffer();
  110           rc.append(super.getFieldRepr());
  111           rc.append(", $" + wage);
  112           return rc.toString();
  113       }
  114   
  115       /**
  116        * 
  117        * Returns <code>true</code> if all the fields of this instance are
  118        * deep equal to the coresponding fields of the specified
  119        * JPAAppPartTimeEmployee. 
  120        * 
  121        * 
  122        * @param other the object with which to compare.
  123        * @param helper EqualityHelper to keep track of instances that have
  124        * already been processed.
  125        * @return <code>true</code> if all the fields are deep equal;
  126        * <code>false</code> otherwise.
  127        * @throws ClassCastException if the specified instances' type prevents
  128        * it from being compared to this instance.
  129        */
  130       public boolean deepCompareFields(Object other, 
  131                                           EqualityHelper helper) {
  132           JPAAppPartTimeEmployee otherEmp = (JPAAppPartTimeEmployee)other;
  133           String where = "JPAPartTimeEmployee<" + getPersonid() + ">";
  134           return super.deepCompareFields(otherEmp, helper) &
  135               helper.closeEnough(wage, otherEmp.getWage(), where + ".wage");
  136       }
  137   }

Save This Page
Home » jdo2-tck-2.3-ea-src » org.apache.jdo.tck.pc.companyAnnotatedJPA » [javadoc | source]