You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2017/10/31 21:03:41 UTC

svn commit: r1813933 - /uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIndex.java

Author: schor
Date: Tue Oct 31 21:03:41 2017
New Revision: 1813933

URL: http://svn.apache.org/viewvc?rev=1813933&view=rev
Log:
[UIMA-5633] generics improvement, plus implement subIndex for indexes

Modified:
    uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIndex.java

Modified: uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIndex.java
URL: http://svn.apache.org/viewvc/uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIndex.java?rev=1813933&r1=1813932&r2=1813933&view=diff
==============================================================================
--- uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIndex.java (original)
+++ uima/uv3/uimaj-v3/trunk/uimaj-core/src/main/java/org/apache/uima/cas/impl/LowLevelIndex.java Tue Oct 31 21:03:41 2017
@@ -141,9 +141,14 @@ public interface LowLevelIndex<T extends
    * @param <U> the type the subindex is over
    * @return the index but just over this subtype
    */
-  default <U extends T> LowLevelIndex<U> getSubIndex(TypeImpl ti) {
+  default <U extends T> LowLevelIndex<U> getSubIndex(Type type) {
+    TypeImpl ti = (TypeImpl) type;
     return getCasImpl().indexRepository.getIndexBySpec(ti.getCode(), getIndexingStrategy(), (FSIndexComparatorImpl) getComparatorForIndexSpecs());
   }
+  
+  default <U extends T> LowLevelIndex<U> getSubIndex(Class<? extends TOP> clazz) {
+    return getSubIndex(this.getCasImpl().getCasType(clazz));
+  }
 
   /**
    * @return for annotation indexes, an conservative estimate the maximum span between begin and end
@@ -157,27 +162,27 @@ public interface LowLevelIndex<T extends
   boolean isSorted();
   
   @Override
-  default <N extends FeatureStructure> SelectFSs<N> select() {
-    return ((SelectFSs_impl)getCasImpl().select()).index(this);
+  default SelectFSs<T> select() {
+    return ((SelectFSs_impl<T>)getCasImpl().select()).index(this);
   }
 
   @Override
-  default <N extends FeatureStructure> SelectFSs<N> select(Type type) {
-    return ((SelectFSs_impl)select()).type(type);
+  default <N extends T> SelectFSs<N> select(Type type) {
+    return ((SelectFSs_impl)select()).type(type); // need cast to impl because type() not in interface
   }
 
   @Override
-  default <N extends FeatureStructure> SelectFSs<N> select(Class<N> clazz) {
+  default <N extends T> SelectFSs<N> select(Class<N> clazz) {
     return ((SelectFSs_impl)select()).type(clazz);
   }
 
   @Override
-  default <N extends FeatureStructure> SelectFSs<N> select(int jcasType) {
+  default <N extends T> SelectFSs<N> select(int jcasType) {
     return ((SelectFSs_impl)select()).type(jcasType);
   }
 
   @Override
-  default <N extends FeatureStructure> SelectFSs<N> select(String fullyQualifiedTypeName) {
+  default <N extends T> SelectFSs<N> select(String fullyQualifiedTypeName) {
     return ((SelectFSs_impl)select()).type(fullyQualifiedTypeName);
   }