public abstract class AuthIdentityModification<T extends AuthIdentity> extends Object
AuthIdentity as part of a create
or update operation using AuthIdentityManager.createIdentity(String, AuthIdentityModification) or
AuthIdentityManager.updateIdentity(String, AuthIdentityModification), respectively. Subclasses should
override to instantiate a new instance from one of the build methods, as well as add any additional modifiers
for attributes specific to the AuthIdentity implementation if necessary.| Constructor and Description |
|---|
AuthIdentityModification() |
| Modifier and Type | Method and Description |
|---|---|
AuthIdentityModification<T> |
addRoles(Set<String> roles) |
AuthIdentityModification<T> |
addRoles(String... roles) |
abstract T |
buildFrom(T identity)
Subclasses should return a new AuthIdentity instance matching the provided entity plus any modifications
set in this object.
|
abstract T |
buildNew(String id)
Subclasses should return a new AuthIdentity instance based only on the attributes set in this object with
the provided ID.
|
protected String |
getDescription() |
protected String |
getOwner() |
protected Set<String> |
getUpdatedRolesFrom(Set<String> roles)
Helper method for subclasses which, given a set of roles, returns a new set of roles with all added and removed
roles from this modification applied.
|
protected boolean |
isDescriptionPresent() |
protected boolean |
isOwnerPresent() |
AuthIdentityModification<T> |
removeRoles(Set<String> roles) |
AuthIdentityModification<T> |
removeRoles(String... roles) |
AuthIdentityModification<T> |
withDescription(String description) |
AuthIdentityModification<T> |
withOwner(String owner) |
public AuthIdentityModification<T> withOwner(String owner)
public AuthIdentityModification<T> withDescription(String description)
public AuthIdentityModification<T> addRoles(Set<String> roles)
public AuthIdentityModification<T> addRoles(String... roles)
public AuthIdentityModification<T> removeRoles(Set<String> roles)
public AuthIdentityModification<T> removeRoles(String... roles)
protected boolean isOwnerPresent()
protected String getOwner()
protected boolean isDescriptionPresent()
protected String getDescription()
protected Set<String> getUpdatedRolesFrom(Set<String> roles)
public abstract T buildNew(String id)
AuthIdentityImpl identity = createAuthIdentityImplModification()
.withOwner("owner@example.com")
.addRoles("role1")
.buildNew("123");
assert identity.getId().equals("123");
assert identity.getOwner().equals("owner@example.com");
assert identity.getRoles().equals(ImmutableSet.of("role1"));
assert identity.getDescription() == null;
public abstract T buildFrom(T identity)
AuthIdentityImpl before = getAuthIdentityImplFromSomewhere();
assert before.getId().equals("123");
assert before.getOwner.equals("owner@example.com");
assert before.getDescription.equals("Old description");
assert before.getRoles().equals(ImmutableSet.of("role1"));
AuthIdentityImpl after = createAuthIdentityImplModification()
.withDescription("New description")
.addRoles("role2")
.removeRoles("role1")
.buildFrom(before);
assert after.getId().equals("123");
assert after.getOwner.equals("owner@example.com");
assert after.getDescription.equals("New description");
assert after.getRoles().equals(ImmutableSet.of("role2"));
Copyright © 2017. All Rights Reserved.