@Test public void getBinaryValues() { final List<byte[]> jpegPhotos = new ArrayList<>(); jpegPhotos.add("image1".getBytes()); jpegPhotos.add("image2".getBytes()); final List<String> stringJpegPhotos = new ArrayList<>(); stringJpegPhotos.add("aW1hZ2Ux"); stringJpegPhotos.add("aW1hZ2Uy"); final LdapAttribute la = new LdapAttribute(); la.setName("jpegPhoto"); la.addBinaryValues(jpegPhotos); Assert.assertNotNull(la.getStringValue()); Assert.assertNotNull(la.getStringValues()); Assert.assertNotNull(la.getBinaryValue()); Assert.assertNotNull(la.getBinaryValues()); Assert.assertEquals(la.getStringValues().size(), 2); Assert.assertEquals(la.getBinaryValues().size(), 2); Assert.assertTrue(la.getStringValues().contains("aW1hZ2Ux")); Assert.assertTrue(la.getStringValues().contains("aW1hZ2Uy")); Assert.assertEqualsNoOrder(stringJpegPhotos.toArray(new String[2]), la.getStringValues().toArray(new String[2])); Assert.assertEquals(la.getBinaryValues().size(), jpegPhotos.size()); for (byte[] b : jpegPhotos) { Assert.assertTrue(la.getBinaryValues().stream().anyMatch(a -> Arrays.equals(a, b))); } la.clear(); Assert.assertEquals(la.size(), 0); }
public Collection<byte[]> getBinaryValues() { if (attributeValues.isEmpty()) { return Collections.emptySet(); } return attributeValues.stream().map(ByteBuffer::array).collect(Collectors.toUnmodifiableList()); }
LdapAttribute { public Collection<byte[]> getBinaryValues() { if (attributeValues.isEmpty()) { return Collections.emptySet(); } return attributeValues.stream().map(ByteBuffer::array).collect(Collectors.toUnmodifiableList()); } }
LdapAttribute { public Collection<byte[]> getBinaryValues() { if (attributeValues.isEmpty()) { return Collections.emptySet(); } return attributeValues.stream().map(ByteBuffer::array).collect(Collectors.toUnmodifiableList()); } LdapAttribute();  LdapAttribute(final String type);  LdapAttribute(final String type, final byte[]... value);  LdapAttribute(final String type, final String... value); }
LdapAttribute { public Collection<byte[]> getBinaryValues() { if (attributeValues.isEmpty()) { return Collections.emptySet(); } return attributeValues.stream().map(ByteBuffer::array).collect(Collectors.toUnmodifiableList()); } LdapAttribute();  LdapAttribute(final String type);  LdapAttribute(final String type, final byte[]... value);  LdapAttribute(final String type, final String... value); void setName(final String type); boolean isBinary(); void setBinary(final boolean b); void configureBinary(final String... attrNames); String getName(); String getName(final boolean withOptions); List<String> getOptions(); byte[] getBinaryValue(); Collection<byte[]> getBinaryValues(); String getStringValue(); Collection<String> getStringValues(); T getValue(final Function<byte[], T> func); Collection<T> getValues(final Function<byte[] , T> func); void addBinaryValues(final byte[]... value); void addBinaryValues(final Collection<byte[]> values); void addStringValues(final String... value); void addStringValues(final Collection<String> values); void addBufferValues(final ByteBuffer... values); void addBufferValues(final Collection<ByteBuffer> values); @SuppressWarnings("unchecked") void addValues(final Function<T, byte[]> func, final T... value); void addValues(final Function<T, byte[]> func, final Collection<T> values); void removeBinaryValues(final byte[]... value); void removeBinaryValues(final Collection<byte[]> values); void removeStringValues(final String... value); void removeStringValues(final Collection<String> values); void removeBufferValues(final ByteBuffer... values); void removeBufferValues(final Collection<ByteBuffer> values); int size(); void clear(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); static LdapAttribute sort(final LdapAttribute la); static String escapeValue(final String value); static Builder builder(); }
LdapAttribute { public Collection<byte[]> getBinaryValues() { if (attributeValues.isEmpty()) { return Collections.emptySet(); } return attributeValues.stream().map(ByteBuffer::array).collect(Collectors.toUnmodifiableList()); } LdapAttribute();  LdapAttribute(final String type);  LdapAttribute(final String type, final byte[]... value);  LdapAttribute(final String type, final String... value); void setName(final String type); boolean isBinary(); void setBinary(final boolean b); void configureBinary(final String... attrNames); String getName(); String getName(final boolean withOptions); List<String> getOptions(); byte[] getBinaryValue(); Collection<byte[]> getBinaryValues(); String getStringValue(); Collection<String> getStringValues(); T getValue(final Function<byte[], T> func); Collection<T> getValues(final Function<byte[] , T> func); void addBinaryValues(final byte[]... value); void addBinaryValues(final Collection<byte[]> values); void addStringValues(final String... value); void addStringValues(final Collection<String> values); void addBufferValues(final ByteBuffer... values); void addBufferValues(final Collection<ByteBuffer> values); @SuppressWarnings("unchecked") void addValues(final Function<T, byte[]> func, final T... value); void addValues(final Function<T, byte[]> func, final Collection<T> values); void removeBinaryValues(final byte[]... value); void removeBinaryValues(final Collection<byte[]> values); void removeStringValues(final String... value); void removeStringValues(final Collection<String> values); void removeBufferValues(final ByteBuffer... values); void removeBufferValues(final Collection<ByteBuffer> values); int size(); void clear(); @Override boolean equals(final Object o); @Override int hashCode(); @Override String toString(); static LdapAttribute sort(final LdapAttribute la); static String escapeValue(final String value); static Builder builder();  }