openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r1069984 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/ openjpa-persistence/src/main/java/org/apache/openjpa/persistence/
Date Fri, 11 Feb 2011 23:34:16 GMT
Author: ppoddar
Date: Fri Feb 11 23:34:15 2011
New Revision: 1069984

URL: http://svn.apache.org/viewvc?rev=1069984&view=rev
Log:
OPENJPA-1050: Generics for extent

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingExtent.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Extent.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ExtentImpl.java
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/InMemoryExpressionFactory.java
    openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ExtentImpl.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingExtent.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingExtent.java?rev=1069984&r1=1069983&r2=1069984&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingExtent.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DelegatingExtent.java
Fri Feb 11 23:34:15 2011
@@ -36,27 +36,27 @@ import org.apache.openjpa.util.RuntimeEx
  * @author Abe White
  * @nojavadoc
  */
-public class DelegatingExtent
-    implements Extent {
+public class DelegatingExtent<T>
+    implements Extent<T> {
 
-    private final Extent _extent;
-    private final DelegatingExtent _del;
+    private final Extent<T> _extent;
+    private final DelegatingExtent<T> _del;
     private final RuntimeExceptionTranslator _trans;
 
     /**
      * Constructor; supply delegate.
      */
-    public DelegatingExtent(Extent extent) {
+    public DelegatingExtent(Extent<T> extent) {
         this(extent, null);
     }
 
     /**
      * Constructor; supply delegate and exception translator.
      */
-    public DelegatingExtent(Extent extent, RuntimeExceptionTranslator trans) {
+    public DelegatingExtent(Extent<T> extent, RuntimeExceptionTranslator trans) {
         _extent = extent;
         if (extent instanceof DelegatingExtent)
-            _del = (DelegatingExtent) extent;
+            _del = (DelegatingExtent<T>) extent;
         else
             _del = null;
         _trans = trans;
@@ -65,14 +65,14 @@ public class DelegatingExtent
     /**
      * Return the direct delegate.
      */
-    public Extent getDelegate() {
+    public Extent<T> getDelegate() {
         return _extent;
     }
 
     /**
      * Return the native delegate.
      */
-    public Extent getInnermostDelegate() {
+    public Extent<T> getInnermostDelegate() {
         return (_del == null) ? _extent : _del.getInnermostDelegate();
     }
 
@@ -84,7 +84,7 @@ public class DelegatingExtent
         if (other == this)
             return true;
         if (other instanceof DelegatingExtent)
-            other = ((DelegatingExtent) other).getInnermostDelegate();
+            other = ((DelegatingExtent<T>) other).getInnermostDelegate();
         return getInnermostDelegate().equals(other);
     }
 
@@ -95,7 +95,7 @@ public class DelegatingExtent
         return (_trans == null) ? re : _trans.translate(re);
     }
 
-    public Class getElementType() {
+    public Class<T> getElementType() {
         try {
             return _extent.getElementType();
         } catch (RuntimeException re) {
@@ -143,7 +143,7 @@ public class DelegatingExtent
         }
     }
 
-    public List list() {
+    public List<T> list() {
         try {
             return _extent.list();
         } catch (RuntimeException re) {
@@ -151,7 +151,7 @@ public class DelegatingExtent
         }
     }
 
-    public Iterator iterator() {
+    public Iterator<T> iterator() {
         try {
             return _extent.iterator();
         } catch (RuntimeException re) {

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Extent.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Extent.java?rev=1069984&r1=1069983&r2=1069984&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Extent.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/Extent.java Fri Feb
11 23:34:15 2011
@@ -28,7 +28,7 @@ import java.util.List;
  * @author Abe White
  * @author Patrick Linskey
  */
-public interface Extent {
+public interface Extent<T> {
 
     /**
      * Return the (mutable) fetch configuration for this extent.
@@ -52,12 +52,12 @@ public interface Extent {
      * work correctly, but if the extent represents a large data set, this
      * method may be quite slow and may consume quite a bit of memory.
      */
-    public List list();
+    public List<T> list();
 
     /**
      * Return an iterator over the extent members.
      */
-    public Iterator iterator();
+    public Iterator<T> iterator();
 
     /**
      * The broker that generated the extent.
@@ -67,7 +67,7 @@ public interface Extent {
     /**
      * The class of extent elements.
      */
-    public Class getElementType();
+    public Class<T> getElementType();
 
     /**
      * Whether the extent includes subclasses.

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ExtentImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ExtentImpl.java?rev=1069984&r1=1069983&r2=1069984&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ExtentImpl.java (original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ExtentImpl.java Fri
Feb 11 23:34:15 2011
@@ -44,13 +44,13 @@ import org.apache.openjpa.util.OpenJPAEx
  * @author Patrick Linskey
  * @nojavadoc
  */
-public class ExtentImpl
-    implements Extent {
+public class ExtentImpl<T>
+    implements Extent<T> {
 
     private static final ClassMetaData[] EMPTY_METAS = new ClassMetaData[0];
 
     private final Broker _broker;
-    private final Class _type;
+    private final Class<T> _type;
     private final boolean _subs;
     private final FetchConfiguration _fc;
     private final ReentrantLock _lock;
@@ -66,7 +66,7 @@ public class ExtentImpl
      * @param type the candidate class
      * @param subs whether subclasses are included in the extent
      */
-    ExtentImpl(Broker broker, Class type, boolean subs,
+    ExtentImpl(Broker broker, Class<T> type, boolean subs,
         FetchConfiguration fetch) {
         _broker = broker;
         _type = type;
@@ -95,9 +95,9 @@ public class ExtentImpl
         _ignore = ignoreChanges;
     }
 
-    public List list() {
-        List list = new ArrayList();
-        Iterator itr = iterator();
+    public List<T> list() {
+        List<T> list = new ArrayList<T>();
+        Iterator<T> itr = iterator();
         try {
             while (itr.hasNext())
                 list.add(itr.next());
@@ -107,7 +107,7 @@ public class ExtentImpl
         }
     }
 
-    public Iterator iterator() {
+    public Iterator<T> iterator() {
         _broker.assertNontransactionalRead();
         CloseableIterator citr = null;
         try {
@@ -169,7 +169,7 @@ public class ExtentImpl
         return _broker;
     }
 
-    public Class getElementType() {
+    public Class<T> getElementType() {
         return _type;
     }
 
@@ -215,13 +215,13 @@ public class ExtentImpl
     /**
      * Closeable iterator.
      */
-    private static interface CloseableIterator
-        extends Closeable, Iterator {
+    private static interface CloseableIterator<T>
+        extends Closeable, Iterator<T> {
 
         /**
          * Set the extent to remove self from on close.
          */
-        public void setRemoveOnClose(ExtentImpl extent);
+        public void setRemoveOnClose(ExtentImpl<T> extent);
     }
 
     /**
@@ -231,7 +231,7 @@ public class ExtentImpl
         extends IteratorChain
         implements CloseableIterator {
 
-        private ExtentImpl _extent = null;
+        private ExtentImpl<?> _extent = null;
         private boolean _closed = false;
 
         public boolean hasNext() {
@@ -342,7 +342,7 @@ public class ExtentImpl
             if (!_broker.isNew(o))
                 return false;
 
-            Class type = o.getClass();
+            Class<?> type = o.getClass();
             if (!_subs && type != _type)
                 return false;
             if (_subs && !_type.isAssignableFrom(type))

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/InMemoryExpressionFactory.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/InMemoryExpressionFactory.java?rev=1069984&r1=1069983&r2=1069984&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/InMemoryExpressionFactory.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/exps/InMemoryExpressionFactory.java
Fri Feb 11 23:34:15 2011
@@ -53,7 +53,7 @@ public class InMemoryExpressionFactory
     private static final Object UNIQUE = new Object();
 
     // list of unbound variables in this query
-    private List _unbounds = null;
+    private List<UnboundVariable> _unbounds = null;
 
     /**
      * Tests whether the given candidate matches the given type and this
@@ -90,8 +90,8 @@ public class InMemoryExpressionFactory
             return exp.evaluate(candidate, candidate, ctx, params);
 
         // grab the extent for this variable
-        UnboundVariable var = (UnboundVariable) _unbounds.get(i);
-        Iterator itr = ctx.extentIterator(var.getType(), true, null, false);
+        UnboundVariable var = _unbounds.get(i);
+        Iterator<Object> itr = ctx.extentIterator(var.getType(), true, null, false);
         try {
             // if the extent was empty, then alias the variable to null
             if (!itr.hasNext()) {
@@ -191,7 +191,7 @@ public class InMemoryExpressionFactory
             return exp.evaluate(group, ctx, params);
 
         // grab the extent for this variable
-        UnboundVariable var = (UnboundVariable) _unbounds.get(i);
+        UnboundVariable var = _unbounds.get(i);
         Extent extent = ctx.getBroker().newExtent(var.getType(), true);
         Iterator itr = extent.iterator();
         try {
@@ -533,7 +533,7 @@ public class InMemoryExpressionFactory
     public Value newUnboundVariable(String name, Class type) {
         UnboundVariable var = new UnboundVariable(type);
         if (_unbounds == null)
-            _unbounds = new ArrayList(3);
+            _unbounds = new ArrayList<UnboundVariable>(3);
         _unbounds.add(var);
         return var;
     }

Modified: openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ExtentImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ExtentImpl.java?rev=1069984&r1=1069983&r2=1069984&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ExtentImpl.java
(original)
+++ openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/ExtentImpl.java
Fri Feb 11 23:34:15 2011
@@ -40,8 +40,7 @@ public class ExtentImpl<T>
     /**
      * Constructor; supply delegate.
      */
-    public ExtentImpl(EntityManagerImpl em,
-        org.apache.openjpa.kernel.Extent extent) {
+    public ExtentImpl(EntityManagerImpl em, org.apache.openjpa.kernel.Extent<T> extent)
{
         _em = em;
         _extent = new DelegatingExtent(extent,
             PersistenceExceptions.getRollbackTranslator(em));
@@ -50,7 +49,7 @@ public class ExtentImpl<T>
     /**
      * Delegate.
      */
-    public org.apache.openjpa.kernel.Extent getDelegate() {
+    public org.apache.openjpa.kernel.Extent<T> getDelegate() {
         return _extent.getDelegate();
     }
 



Mime
View raw message