Interface NameRewriter

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface NameRewriter
A name rewriter. Name rewriters transform names from one form to another for various purposes, including (but not limited to):
  • Normalizing case
  • Trimming extra whitespace
  • Mapping one naming scheme to another (e.g. "user@realm" to/from "realm/user" or similar)
  • Removing a realm component (e.g. "user@realm" to "user")
A name rewriter may also be used to perform a validation step on the syntax of the name. If the rewriter returns null, the name is not valid according to the rules of the rewriter.
Author:
David M. Lloyd
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final NameRewriter
    The simple identity name rewriter, which does no rewriting.
  • Method Summary

    Modifier and Type
    Method
    Description
    aggregate(NameRewriter... nameRewriters)
    Create a name rewriter which aggregates the given name rewriters; the first rewriter which successfully rewrites the name is used.
    aggregate(NameRewriter rewriter1, NameRewriter rewriter2)
    Create a name rewriter which aggregates the given name rewriters; the first rewriter which successfully rewrites the name is used.
    Get this name rewriter as a principal rewriter that applies only to NamePrincipal instances.
    chain(NameRewriter... nameRewriters)
    Create a name rewriter which chains the given name rewriters; the name will be rewritten through the given rewriters in order and then returned.
    chain(NameRewriter rewriter1, NameRewriter rewriter2)
    Create a name rewriter which chains the given name rewriters; the name will be rewritten through the given rewriters in order and then returned.
    Create a name rewriter which always returns the same name.
    rewriteName(String original)
    Rewrite a name.
  • Field Details

    • IDENTITY_REWRITER

      static final NameRewriter IDENTITY_REWRITER
      The simple identity name rewriter, which does no rewriting.
  • Method Details

    • rewriteName

      String rewriteName(String original)
      Rewrite a name. Must not return null.
      Parameters:
      original - the original name (must not be null)
      Returns:
      the rewritten name, or null if the name is invalid
    • asPrincipalRewriter

      default UnaryOperator<Principal> asPrincipalRewriter()
      Get this name rewriter as a principal rewriter that applies only to NamePrincipal instances.
      Returns:
      the principal rewriter (not null)
    • chain

      static NameRewriter chain(NameRewriter rewriter1, NameRewriter rewriter2)
      Create a name rewriter which chains the given name rewriters; the name will be rewritten through the given rewriters in order and then returned. If any rewriter returns null, then null is returned.
      Parameters:
      rewriter1 - the first name rewriter (must not be null)
      rewriter2 - the second name rewriter (must not be null)
      Returns:
      the name rewriter (not null)
    • chain

      static NameRewriter chain(NameRewriter... nameRewriters)
      Create a name rewriter which chains the given name rewriters; the name will be rewritten through the given rewriters in order and then returned. If any rewriter returns null, then null is returned.
      Parameters:
      nameRewriters - the name rewriters (must not be null, cannot have null elements)
      Returns:
      the name rewriter (not null)
    • aggregate

      static NameRewriter aggregate(NameRewriter rewriter1, NameRewriter rewriter2)
      Create a name rewriter which aggregates the given name rewriters; the first rewriter which successfully rewrites the name is used. If all the rewriters return null, then null is returned.
      Parameters:
      rewriter1 - the first name rewriter (must not be null)
      rewriter2 - the second name rewriter (must not be null)
      Returns:
      the name rewriter (not null)
    • aggregate

      static NameRewriter aggregate(NameRewriter... nameRewriters)
      Create a name rewriter which aggregates the given name rewriters; the first rewriter which successfully rewrites the name is used. If all the rewriters return null, then null is returned.
      Parameters:
      nameRewriters - the name rewriters (must not be null, cannot have null elements)
      Returns:
      the name rewriter (not null)
    • constant

      static NameRewriter constant(String name)
      Create a name rewriter which always returns the same name.
      Parameters:
      name - the name to return
      Returns:
      the name