@Test(expected = AssertionError.class) public void testSetRequiredRoles() { final RoleAccessAssertion assertion = new RoleAccessAssertion(); assertion.setRequiredRoles(Collections.singleton("ROLE_USER")); assertion.setRequiredRoles(Collections.singleton("ROLE_USER")); }
@SuppressWarnings("unchecked") public AccessAssertion setRequiredRoles(final Collection<String> assertionRequiredRoles) { if (this.requiredRoles != null) { throw new AssertionError(getClass() + "#setRequiredRoles() may only be called once any further calls" + " result in an exception"); } if (assertionRequiredRoles == null) { this.requiredRoles = Collections.unmodifiableSet(Collections.emptySet()); } else { if (assertionRequiredRoles instanceof Set) { Set roles = (Set) assertionRequiredRoles; this.requiredRoles = Collections.unmodifiableSet(roles); } else { this.requiredRoles = Collections.unmodifiableSet(new HashSet<>(assertionRequiredRoles)); } } return this; }
RoleAccessAssertion implements AccessAssertion { @SuppressWarnings("unchecked") public AccessAssertion setRequiredRoles(final Collection<String> assertionRequiredRoles) { if (this.requiredRoles != null) { throw new AssertionError(getClass() + "#setRequiredRoles() may only be called once any further calls" + " result in an exception"); } if (assertionRequiredRoles == null) { this.requiredRoles = Collections.unmodifiableSet(Collections.emptySet()); } else { if (assertionRequiredRoles instanceof Set) { Set roles = (Set) assertionRequiredRoles; this.requiredRoles = Collections.unmodifiableSet(roles); } else { this.requiredRoles = Collections.unmodifiableSet(new HashSet<>(assertionRequiredRoles)); } } return this; } }
RoleAccessAssertion implements AccessAssertion { @SuppressWarnings("unchecked") public AccessAssertion setRequiredRoles(final Collection<String> assertionRequiredRoles) { if (this.requiredRoles != null) { throw new AssertionError(getClass() + "#setRequiredRoles() may only be called once any further calls" + " result in an exception"); } if (assertionRequiredRoles == null) { this.requiredRoles = Collections.unmodifiableSet(Collections.emptySet()); } else { if (assertionRequiredRoles instanceof Set) { Set roles = (Set) assertionRequiredRoles; this.requiredRoles = Collections.unmodifiableSet(roles); } else { this.requiredRoles = Collections.unmodifiableSet(new HashSet<>(assertionRequiredRoles)); } } return this; }  }
RoleAccessAssertion implements AccessAssertion { @SuppressWarnings("unchecked") public AccessAssertion setRequiredRoles(final Collection<String> assertionRequiredRoles) { if (this.requiredRoles != null) { throw new AssertionError(getClass() + "#setRequiredRoles() may only be called once any further calls" + " result in an exception"); } if (assertionRequiredRoles == null) { this.requiredRoles = Collections.unmodifiableSet(Collections.emptySet()); } else { if (assertionRequiredRoles instanceof Set) { Set roles = (Set) assertionRequiredRoles; this.requiredRoles = Collections.unmodifiableSet(roles); } else { this.requiredRoles = Collections.unmodifiableSet(new HashSet<>(assertionRequiredRoles)); } } return this; }  @SuppressWarnings("unchecked") AccessAssertion setRequiredRoles(final Collection<String> assertionRequiredRoles); @Override void assertAccess(final String resourceDescription, final Object protectedResource); @Override JSONObject marshal(); @Override void unmarshal(final JSONObject encodedAssertion); @Override void validate(final List<Throwable> validationErrors, final Configuration configuration); @Override boolean equals(final Object o); @Override int hashCode(); @Override AccessAssertion copy(); }
RoleAccessAssertion implements AccessAssertion { @SuppressWarnings("unchecked") public AccessAssertion setRequiredRoles(final Collection<String> assertionRequiredRoles) { if (this.requiredRoles != null) { throw new AssertionError(getClass() + "#setRequiredRoles() may only be called once any further calls" + " result in an exception"); } if (assertionRequiredRoles == null) { this.requiredRoles = Collections.unmodifiableSet(Collections.emptySet()); } else { if (assertionRequiredRoles instanceof Set) { Set roles = (Set) assertionRequiredRoles; this.requiredRoles = Collections.unmodifiableSet(roles); } else { this.requiredRoles = Collections.unmodifiableSet(new HashSet<>(assertionRequiredRoles)); } } return this; }  @SuppressWarnings("unchecked") AccessAssertion setRequiredRoles(final Collection<String> assertionRequiredRoles); @Override void assertAccess(final String resourceDescription, final Object protectedResource); @Override JSONObject marshal(); @Override void unmarshal(final JSONObject encodedAssertion); @Override void validate(final List<Throwable> validationErrors, final Configuration configuration); @Override boolean equals(final Object o); @Override int hashCode(); @Override AccessAssertion copy();  }