public boolean hasChains() { return !com.stormpath.sdk.lang.Collections.isEmpty(this.filterChains); }
/** * @since 1.2.0 */ public void setOptionalFieldNames(String... optionalFieldNames) { this.optionalFieldNames = Collections.toList(optionalFieldNames); }
public static <T> T[] toArray(Collection<T> c, Class<T> type) { T[] array = (T[])Array.newInstance(type, size(c)); return c.toArray(array); }
/** * a new List that contains the specified elements or an empty collection if the elements are null or empty. * * @param elements the elements to put in the list. * @param <T> the type of elements in the collection * @return a new List that contains the specified elements or an empty collection if the elements are null or empty. * @since 1.0.RC3 */ public static <T> List<T> toList(Collection<T> elements) { if (elements instanceof List) { return (List<T>) elements; } if (isEmpty(elements)) { return java.util.Collections.emptyList(); } // Avoid integer overflow when a large array is passed in int capacity = computeListCapacity(elements.size()); ArrayList<T> list = new ArrayList<T>(capacity); for (T element : elements) { list.add(element); } return list; }
/** * Find a single value of one of the given types in the given Collection: * searching the Collection for a value of the first type, then * searching for a value of the second type, etc. * * @param collection the collection to search * @param types the types to look for, in prioritized order * @return a value of one of the given types found if there is a clear match, * or <code>null</code> if none or more than one such value found */ public static Object findValueOfType(Collection<?> collection, Class<?>[] types) { if (isEmpty(collection) || Objects.isEmpty(types)) { return null; } for (Class<?> type : types) { Object value = findValueOfType(collection, type); if (value != null) { return value; } } return null; }
protected void setParts(String wildcardString, boolean caseSensitive) { if (wildcardString == null || wildcardString.trim().length() == 0) { throw new IllegalArgumentException("Wildcard string cannot be null or empty. Make sure permission strings are properly formatted."); } wildcardString = wildcardString.trim(); List<String> parts = Collections.toList(wildcardString.split(PART_DIVIDER_TOKEN)); this.parts = new ArrayList<Set<String>>(); for (String part : parts) { Set<String> subparts = Collections.toSet(part.split(SUBPART_DIVIDER_TOKEN)); if (subparts.isEmpty()) { throw new IllegalArgumentException("Wildcard string cannot contain parts with only dividers. Make sure permission strings are properly formatted."); } this.parts.add(subparts); } if (this.parts.isEmpty()) { throw new IllegalArgumentException("Wildcard string cannot contain only dividers. Make sure permission strings are properly formatted."); } }
/** * a new List that contains the specified elements or an empty collection if the elements are null or empty. * * @param elements the elements to put in the list. * @param <T> the type of elements in the collection * @return a new List that contains the specified elements or an empty collection if the elements are null or empty. * @since 1.0.RC3 */ public static <T> List<T> toList(T... elements) { if (elements == null || elements.length == 0) { return java.util.Collections.emptyList(); } // Avoid integer overflow when a large array is passed in int capacity = computeListCapacity(elements.length); ArrayList<T> list = new ArrayList<T>(capacity); java.util.Collections.addAll(list, elements); return list; }
public boolean hasChains() { return !com.stormpath.sdk.lang.Collections.isEmpty(this.filterChains); }
/** * @since 1.2.0 */ public void setOptionalFieldNames(String... optionalFieldNames) { this.optionalFieldNames = Collections.toList(optionalFieldNames); }
new LinkedHashMap<>(Collections.size(updatedPropertyNames));
/** * Determine whether the given Collection only contains a single unique object. * * @param collection the Collection to check * @return <code>true</code> if the collection contains a single reference or * multiple references to the same instance, <code>false</code> else */ public static boolean hasUniqueObject(Collection collection) { if (isEmpty(collection)) { return false; } boolean hasCandidate = false; Object candidate = null; for (Object elem : collection) { if (!hasCandidate) { hasCandidate = true; candidate = elem; } else if (candidate != elem) { return false; } } return true; }
public void setDefaultFieldNames(String... defaultFieldNames) { this.defaultFieldNames = Collections.toList(defaultFieldNames); }
new LinkedHashMap<>(Collections.size(updatedPropertyNames));
public void addFilterClasses(Map<String, Class<? extends Filter>> classes) { if (Collections.isEmpty(classes)) { return; } this.configuredFilters.putAll(classes); }
public void setDisabledFieldNames(String... disabledFieldNames) { this.disabledFieldNames = Collections.toList(disabledFieldNames); }
public void addFilterClasses(Map<String, Class<? extends Filter>> classes) { if (Collections.isEmpty(classes)) { return; } this.configuredFilters.putAll(classes); }
public void setDisabledFieldNames(String... disabledFieldNames) { this.disabledFieldNames = Collections.toList(disabledFieldNames); }
/** * Assert that a collection has elements; that is, it must not be * <code>null</code> and must have at least one element. * <pre class="code">Assert.notEmpty(collection, "Collection must have elements");</pre> * @param collection the collection to check * @param message the exception message to use if the assertion fails * @throws IllegalArgumentException if the collection is <code>null</code> or has no elements */ public static void notEmpty(Collection collection, String message) { if (Collections.isEmpty(collection)) { throw new IllegalArgumentException(message); } }
public void setDefaultFieldNames(String... defaultFieldNames) { this.defaultFieldNames = Collections.toList(defaultFieldNames); }
/** * Assert that a Map has entries; that is, it must not be <code>null</code> * and must have at least one entry. * <pre class="code">Assert.notEmpty(map, "Map must have entries");</pre> * @param map the map to check * @param message the exception message to use if the assertion fails * @throws IllegalArgumentException if the map is <code>null</code> or has no entries */ public static void notEmpty(Map map, String message) { if (Collections.isEmpty(map)) { throw new IllegalArgumentException(message); } }