package com.playmoweb.store2store.utils;


/**
 * Bind a key to a sorting mode
 * @author  Thibaud Giovannetti
 * @by      Playmoweb
 * @date    08/02/2017.
 */
public final class SortingMode {
    public static final SortingMode DEFAULT = new SortingMode("id", SortType.ASCENDING);
    public final String key;
    public final SortType sort;

    public SortingMode(String k, SortType s) {
        key = k;
        sort = s;
    }
}

@@ -36,16 +36,76 @@
 tils;%0A%0A%0A
+import java.util.AbstractMap;%0Aimport java.util.LinkedList;%0A%0A
 /**%0A * B
@@ -357,52 +357,608 @@
 nal 
-String key;%0A    public final SortType sort;%0A
+LinkedList%3CAbstractMap.SimpleEntry%3CString, SortType%3E%3E entries = new LinkedList%3C%3E();%0A%0A    public SortingMode(String key, SortType sortType) %7B%0A        and(key, sortType);%0A    %7D%0A%0A    /**%0A     * Create a list of Sorting rules with the same SortType%0A     */%0A    public SortingMode(String%5B%5D keys, SortType sortType) %7B%0A        for(String k : keys)%7B%0A            if(k != null)%7B%0A                this.and(k, sortType);%0A            %7D%0A        %7D%0A    %7D%0A%0A    /**%0A     * Create a list of Sorting rules mapped by position in array%0A     * @warn    If the arrays have a different size, an exception will be throw%0A     */
 %0A   
@@ -983,18 +983,23 @@
 e(String
- k
+%5B%5D keys
 , SortTy
@@ -1004,47 +1004,854 @@
 Type
- s) %7B%0A        key = k;%0A        sort = s
+%5B%5D sortTypes) %7B%0A        if(keys.length != sortTypes.length)%7B%0A            throw new IllegalArgumentException(%22The String%5B%5D (keys) and the SortType%5B%5D arrays must have the same size%22);%0A        %7D%0A%0A        for (int i = 0; i %3C keys.length; i++) %7B%0A            if(keys%5Bi%5D != null && sortTypes%5Bi%5D != null)%7B%0A                and(keys%5Bi%5D, sortTypes%5Bi%5D);%0A            %7D%0A        %7D%0A    %7D%0A%0A    /**%0A     * Add a sort rule%0A     * @note    This rule is always added at the end and will apply after previous ones.%0A     */%0A    public SortingMode and(String key, SortType sortType)%7B%0A        entries.add(new AbstractMap.SimpleEntry%3C%3E(key, sortType));%0A        return this;%0A    %7D%0A%0A    /**%0A     * Build a new SortingMode object to allow static chaining%0A     */%0A    public static SortingMode with(String key, SortType sortType)%7B%0A        return new SortingMode(key, sortType)
 ;%0A  

Add SortingMode as array