Project

General

Profile

« Previous | Next » 

Revision a120b5f6

Added by Patrick Plitzner almost 6 years ago

ref #6526 extract comparator and add another for TypeDesignationBase

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/name/TypeDesignationSetManager.java
258 258
           TypeDesignationWorkingSet typeDesignationWorkingSet = stringsByTypeByBaseEntity.get(baseEntityRef);
259 259
           // order the TypeDesignationStatusBase keys
260 260
            List<TypeDesignationStatusBase<?>> keyList = new LinkedList<>(typeDesignationWorkingSet.keySet());
261
            Collections.sort(keyList, new Comparator<TypeDesignationStatusBase>() {
262
                @SuppressWarnings("unchecked")
263
                @Override
264
                public int compare(TypeDesignationStatusBase o1, TypeDesignationStatusBase o2) {
265
                    // fix inverted order of cdm terms by -1*
266
                    if(o1 == null && o2 == null || o1 instanceof NullTypeDesignationStatus && o2 instanceof NullTypeDesignationStatus){
267
                        return 0;
268
                    }
269
                    if(o1 == null || o1 instanceof NullTypeDesignationStatus){
270
                        return -1;
271
                    }
272

  
273
                    if(o2 == null || o2 instanceof NullTypeDesignationStatus){
274
                        return 1;
275
                    }
276
                    return -1 * o1.compareTo(o2);
277
                }
278
            });
261
            Collections.sort(keyList, new TypeDesignationStatusComparator());
279 262
            // new LinkedHashMap for the ordered TypeDesignationStatusBase keys
280 263
            TypeDesignationWorkingSet orderedStringsByOrderedTypes = new TypeDesignationWorkingSet(
281 264
                    typeDesignationWorkingSet.getBaseEntity(),

Also available in: Unified diff