/** * Gets the list-item matching the given hash against the list * * @param <T> the object type * @param hash the hashcode to match * @param list the {@link List} to search in * @return the list-item or {@code null} if not found */ public static synchronized <T> T fromHash(int hash, List<T> list) { int index = ListUtils.indexOf(hash, list); if (index > -1) { return list.get(index); } return null; }
/** * Returns a sub list of items of type T having their textual representation (toString()) * containing the search criteria<br> * The max size of the sub list is {@link #MAX} * * @param <T> the type * @param search search criteria * @param list reference list * @return the sub list */ public static <T> List<T> contains(String search, List<T> list) { return ListUtils.contains(search, list, MAX); }
/** * Utility method to move a list-item at a new position in the specified list<br> * This method will use the hashcode of the list-item to retrieve it against the list. * * @param <T> the object type * @param list the {@link List} * @param item the item * @param index the position to move to */ public static synchronized <T> void move(final T item, int index, final List<T> list) { if (index < list.size()) { list.add(index, list.remove(ListUtils.indexOf(item.hashCode(), list))); } }
/** * Excludes items from a {@code List} and return a new {@code List} * * @param list the original {@link List} * @param items items to remove * @return a new {@code List} without excluded items */ public static List<String> exclude(List<String> list, String... items) { return ListUtils.exclude(list, Arrays.asList(items)); }
/** * Returns a sub list of items of type T having their textual representation (toString()) starting * with the search criteria<br> * The max size of the sub list is {@link #MAX} * * @param <T> the type * @param search search criteria * @param list reference list * @return the sub list */ public static <T> List<T> startsWith(String search, List<T> list) { return ListUtils.startsWith(search, list, MAX); }