/** * Determine if the given key has values in this collection. * * @param key the key * @return {@code true} if the key has values, {@code false} otherwise */ default boolean containsKey(String key) { return key != null && size(key) > 0; }
/** * Determine if this collection is empty. * * @return {@code true} if the collection is empty, {@code false} otherwise */ default boolean isEmpty() { return size() == 0; }
@Override public int size(String key) { return Attributes.this.size(key); }
@Override public int size() { return Attributes.this.size(); }
public int size() { return attributes.size(key); } }
public int size() { return Attributes.this.size(); } };
/** * Get the last value mapped to the given key. * * @param key the key * @return the value * @throws IndexOutOfBoundsException if there are no values for the given key */ default String getLast(String key) { return get(key, size(key) - 1); }
/** * Add a value after the last mapping for the given key. * * @param key the key * @param value the value */ default void addLast(String key, String value) { add(key, size(key), value); }
/** * Remove the last value mapped to the given key. * * @param key the key * @return the value * @throws IndexOutOfBoundsException if there are no values for the given key */ default String removeLast(String key) { return remove(key, size(key) - 1); }
/** * Get the index of the first occurrence of the given value at the given key, if any. * * @param key the key * @param value the value * @return the index, or -1 if the value was not found at the given key */ default int indexOf(String key, String value) { final int size = size(key); for (int i = 0; i < size; i ++) { if (get(key, i).equals(value)) { return i; } } return -1; }
/** * Get the index of the last occurrence of the given value at the given key, if any. * * @param key the key * @param value the value * @return the index, or -1 if the value was not found at the given key */ default int lastIndexOf(String key, String value) { final int size = size(key); for (int i = size - 1; i >= 0; i --) { if (get(key, i).equals(value)) { return i; } } return -1; }
/** * Conditionally set a specific value of a given key to a new value, if the existing value matches the {@code expect} * parameter. * * @param key the key * @param idx the index * @param expect the expected value * @param update the value to set * @return {@code true} if the actual value matched the expected value and was updated, {@code false} otherwise * @throws IndexOutOfBoundsException if {@code idx} is less than 0 or greater than or equal to {@code size(key)} */ default boolean set(String key, int idx, String expect, String update) { Assert.checkNotNullParam("update", update); if (expect == null || idx < 0 || idx >= size(key) || ! get(key, idx).equals(expect)) { return false; } set(key, idx, update); return true; }
/** * Construct a new instance copying mappings from an original attributes collection. * * @param original the original collection */ public MapAttributes(Attributes original) { Assert.checkNotNullParam("original", original); Map<String, EntriesList> map = new HashMap<>(original.size()); for (Entry entry : original.entries()) { final EntriesList entriesList = new EntriesList(entry); if (! entriesList.isEmpty()) map.put(entry.getKey(), entriesList); } this.map = map; }
if (attributes.size(mapping.getName()) != 0) { log.ldapRealmDoesNotSupportSettingFilteredAttribute(mapping.getName(), name); if (attributes.size(mapping.getName()) == 1) { renameTo = attributes.get(mapping.getName(), 0); } else { if (attributes.size(mapping.getName()) == 0) { BasicAttribute attribute = new BasicAttribute(mapping.getLdapName()); modItems.add(new ModificationItem(DirContext.REMOVE_ATTRIBUTE, attribute));
/** * Determine if the given key has values in this collection. * * @param key the key * @return {@code true} if the key has values, {@code false} otherwise */ default boolean containsKey(String key) { return key != null && size(key) > 0; }
/** * Determine if the given key has values in this collection. * * @param key the key * @return {@code true} if the key has values, {@code false} otherwise */ default boolean containsKey(String key) { return key != null && size(key) > 0; }
/** * Determine if the given key has values in this collection. * * @param key the key * @return {@code true} if the key has values, {@code false} otherwise */ default boolean containsKey(String key) { return key != null && size(key) > 0; }
/** * Get the last value mapped to the given key. * * @param key the key * @return the value * @throws IndexOutOfBoundsException if there are no values for the given key */ default String getLast(String key) { return get(key, size(key) - 1); }
/** * Remove the last value mapped to the given key. * * @param key the key * @return the value * @throws IndexOutOfBoundsException if there are no values for the given key */ default String removeLast(String key) { return remove(key, size(key) - 1); }
/** * Remove the last value mapped to the given key. * * @param key the key * @return the value * @throws IndexOutOfBoundsException if there are no values for the given key */ default String removeLast(String key) { return remove(key, size(key) - 1); }