Generalize term service method listByTermType()
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 9 Dec 2015 07:59:19 +0000 (08:59 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 9 Dec 2015 07:59:19 +0000 (08:59 +0100)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/view/dataimport/transientServices/TransientTermService.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/TermManager.java
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/store/TermStore.java

index 109a808..d701065 100644 (file)
@@ -857,7 +857,7 @@ public class TransientTermService implements ITermService {
      * @see eu.etaxonomy.cdm.api.service.ITermService#listByTermType(eu.etaxonomy.cdm.model.common.TermType, java.lang.Integer, java.lang.Integer, java.util.List, java.util.List)
      */
     @Override
-    public List<DefinedTermBase<?>> listByTermType(TermType termType, Integer limit, Integer start,
+    public <TERM extends DefinedTermBase> List<TERM> listByTermType(TermType termType, Integer limit, Integer start,
             List<OrderHint> orderHints, List<String> propertyPaths) {
         return defaultService.listByTermType(termType, limit, start, orderHints, propertyPaths);
     }
index 47650d4..822e562 100644 (file)
@@ -52,8 +52,8 @@ public class TermManager extends ContextListenerAdapter{
         * @param clazz
         * @return
         */
-       public List<DefinedTermBase<?>> getPreferredTerms(TermType termType){
-           return getFilteredTerms(TermStore.getTerms(termType, null));
+       public <T extends DefinedTermBase> List<T> getPreferredTerms(TermType termType){
+           return getFilteredTerms(TermStore.<T>getTerms(termType, null));
        }
 
        /**
index 5896718..60cd92d 100644 (file)
@@ -60,7 +60,7 @@ public class TermStore {
         * @param termType the term type
         * @return an alphabetically sorted list of terms
         */
-       public static List<DefinedTermBase<?>> getTerms(TermType termType, Comparator<DefinedTermBase<?>> comparator){
+       public static <TERM extends DefinedTermBase> List<TERM> getTerms(TermType termType, Comparator<TERM> comparator){
         return getTermsFromService(termType, comparator);
        }
 
@@ -105,12 +105,12 @@ public class TermStore {
         * @param comparator
         * @return
         */
-       private static List<DefinedTermBase<?>> getTermsFromService(TermType termType, Comparator<DefinedTermBase<?>> comparator){
+       private static <T extends DefinedTermBase> List<T> getTermsFromService(TermType termType, Comparator<T> comparator){
            if (comparator == null){
-               comparator = new DefaultTermComparator<DefinedTermBase<?>>();
+               comparator = new DefaultTermComparator<T>();
            }
 
-           List<DefinedTermBase<?>> terms = CdmStore.getService(ITermService.class).listByTermType(termType, null, null, null, null);
+           List<T> terms = CdmStore.getService(ITermService.class).listByTermType(termType, null, null, null, null);
            Collections.sort(terms, comparator);
            return terms;
        }