You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by cl...@apache.org on 2005/04/15 23:01:58 UTC

svn commit: r161521 - in incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company: Company.java ICompany.java

Author: clr
Date: Fri Apr 15 14:01:57 2005
New Revision: 161521

URL: http://svn.apache.org/viewcvs?view=rev&rev=161521
Log:
added ICompany interface and refactored Company equals and deepEquals to use ICompany.

Added:
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/ICompany.java
Modified:
    incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/Company.java

Modified: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/Company.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/Company.java?view=diff&r1=161520&r2=161521
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/Company.java (original)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/Company.java Fri Apr 15 14:01:57 2005
@@ -32,7 +32,7 @@
  * This class represents information about a company.
  */
 public class Company 
-    implements Serializable, Comparable, DeepEquality {
+    implements Serializable, Comparable, DeepEquality, ICompany {
 
     private long        companyid;
     private String      name;
@@ -64,6 +64,15 @@
     public long getCompanyid() {
         return companyid;
     }
+    
+    /** 
+     * Set the company id. This is only for the interface and should
+     * not normally be used.
+     * @param companyid the id
+     */
+    public void setCompanyid(long companyid) {
+        this.companyid = companyid;
+    }
 
     /**
      * Get the name of the company.
@@ -171,12 +180,12 @@
      */
     public boolean deepCompareFields(DeepEquality other, 
                                      EqualityHelper helper) {
-        Company otherCompany = (Company)other;
-        return (companyid == otherCompany.companyid) &&
-            helper.equals(name, otherCompany.name) &&
-            helper.equals(founded, otherCompany.founded) &&
-            helper.deepEquals(address, otherCompany.address) &&
-            helper.deepEquals(departments, otherCompany.departments);
+        ICompany otherCompany = (ICompany)other;
+        return (companyid == otherCompany.getCompanyid()) &&
+            helper.equals(name, otherCompany.getName()) &&
+            helper.equals(founded, otherCompany.getFounded()) &&
+            helper.deepEquals(address, otherCompany.getAddress()) &&
+            helper.deepEquals(departments, otherCompany.getDepartments());
     }
     
     /** 
@@ -190,7 +199,7 @@
      * it from being compared to this Object. 
      */
     public int compareTo(Object o) {
-        return compareTo((Company)o);
+        return compareTo((ICompany)o);
     }
 
     /** 
@@ -203,8 +212,8 @@
      * object is less than, equal to, or greater than the specified Company
      * object. 
      */
-    public int compareTo(Company other) {
-        long otherId = other.companyid;
+    public int compareTo(ICompany other) {
+        long otherId = other.getCompanyid();
         return (companyid < otherId ? -1 : (companyid == otherId ? 0 : 1));
     }
     
@@ -215,8 +224,8 @@
      * argument; <code>false</code> otherwise. 
      */
     public boolean equals(Object obj) {
-        if (obj instanceof Company) {
-            return compareTo((Company)obj) == 0;
+        if (obj instanceof ICompany) {
+            return compareTo((ICompany)obj) == 0;
         }
         return false;
     }

Added: incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/ICompany.java
URL: http://svn.apache.org/viewcvs/incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/ICompany.java?view=auto&rev=161521
==============================================================================
--- incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/ICompany.java (added)
+++ incubator/jdo/trunk/tck20/test/java/org/apache/jdo/tck/pc/company/ICompany.java Fri Apr 15 14:01:57 2005
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software 
+ * distributed under the License is distributed on an "AS IS" BASIS, 
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
+ * See the License for the specific language governing permissions and 
+ * limitations under the License.
+ */
+
+package org.apache.jdo.tck.pc.company;
+
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * This interface represents the persistent state of Company.
+ * Javadoc was deliberately omitted because it would distract from
+ * the purpose of the interface.
+ */
+public interface ICompany {
+    Address getAddress();
+    long getCompanyid();
+    Set getDepartments();
+    Date getFounded();
+    String getName();
+    
+    void setAddress(Address a);
+    void setCompanyid(long id);
+    void setDepartments(Set depts);
+    void setFounded(Date date);
+    void setName(String string);
+}