ImmutablePermissions extends AbstractSet<String> implements Permissions { @Override public boolean contains(final String permission, final String... furtherPermissions) { checkNotNull(permission, "permission whose presence is to be checked"); checkNotNull(furtherPermissions, "further permissions whose presence are to be checked"); final HashSet<String> permissionSet = new HashSet<>(); permissionSet.add(permission); permissionSet.addAll(Arrays.asList(furtherPermissions)); return permissions.containsAll(permissionSet); } private  ImmutablePermissions(final Set<String> permissions); static Permissions none(); static Permissions of(final String permission, final String... furtherPermissions); static Permissions of(final Collection<String> permissions); @Override boolean contains(final String permission, final String... furtherPermissions); @Override boolean contains(final Permissions permissions); @Override int size(); @Override JsonArray toJson(); @Nonnull @Override Iterator<String> iterator(); @Override boolean add(final String e); @Override boolean remove(final Object o); @Override boolean addAll(@Nonnull final Collection<? extends String> coll); @Override boolean removeAll(@Nonnull final Collection<?> coll); @Override boolean retainAll(@Nonnull final Collection<?> coll); @Override void clear(); @Override boolean removeIf(final Predicate<? super String> filter);  }
@Test public void containsWorksAsExpected() { underTest = Permissions.newInstance(TestConstants.Policy.PERMISSION_READ, TestConstants.Policy.PERMISSION_WRITE); assertThat(underTest.contains(TestConstants.Policy.PERMISSION_READ)).isTrue(); assertThat(underTest.contains(TestConstants.Policy.PERMISSION_WRITE)).isTrue(); assertThat(underTest.contains(TestConstants.Policy.PERMISSION_READ, TestConstants.Policy.PERMISSION_WRITE)).isTrue(); underTest = Permissions.newInstance(TestConstants.Policy.PERMISSION_READ, TestConstants.Policy.PERMISSION_WRITE); assertThat(underTest.contains(TestConstants.Policy.PERMISSION_READ)).isTrue(); }