/* * */ package fr.devinsy.statoolinfos.properties; import java.util.Comparator; import fr.devinsy.statoolinfos.util.CompareUtils; /** * The Class PathPropertyComparator. */ public class PathPropertyComparator implements Comparator { public enum Sorting { PATH, VALUE } private Sorting sorting; public PathPropertyComparator(final Sorting sorting) { // this.sorting = sorting; } /** * Compare. * * @param alpha * the alpha * @param bravo * the bravo * @return the int */ @Override public int compare(final PathProperty alpha, final PathProperty bravo) { int result; result = compare(alpha, bravo, this.sorting); // return result; } /** * Compare. * * @param alpha * the alpha * @param bravo * the bravo * @param sorting * the sorting * @return the int */ public static int compare(final PathProperty alpha, final PathProperty bravo, final Sorting sorting) { int result; if (sorting == null) { result = 0; } else { switch (sorting) { default: case PATH: result = CompareUtils.compare(getPath(alpha), getPath(bravo)); break; case VALUE: result = CompareUtils.compare(getValue(alpha), getValue(bravo)); break; } } // return result; } /** * Gets the path. * * @param source * the source * @return the path */ public static String getPath(final PathProperty source) { String result; if (source == null) { result = null; } else { result = source.getPath(); } // return result; } /** * Gets the value. * * @param source * the source * @return the value */ public static String getValue(final PathProperty source) { String result; if (source == null) { result = null; } else { result = source.getValue(); } // return result; } }