Class DomainWildcardMappingBuilder<V>

java.lang.Object
io.netty.util.DomainWildcardMappingBuilder<V>
Type Parameters:
V - the type of the value that we map to.

public class DomainWildcardMappingBuilder<V> extends java.lang.Object
Builder that allows to build Mappings that support DNS wildcard matching.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static final class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final V
     
    private final java.util.Map<java.lang.String, V>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DomainWildcardMappingBuilder(int initialCapacity, V defaultValue)
    Constructor with initial capacity of the map holding the mappings
    Constructor with default initial capacity of the map holding the mappings
  • Method Summary

    Modifier and Type
    Method
    Description
    add(java.lang.String hostname, V output)
    Adds a mapping that maps the specified (optionally wildcard) host name to the specified output value.
    Mapping<java.lang.String, V>
    Creates a new instance of an immutable Mapping.
    private java.lang.String
    normalizeHostName(java.lang.String hostname)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • defaultValue

      private final V defaultValue
    • map

      private final java.util.Map<java.lang.String, V> map
  • Constructor Details

    • DomainWildcardMappingBuilder

      public DomainWildcardMappingBuilder(V defaultValue)
      Constructor with default initial capacity of the map holding the mappings
      Parameters:
      defaultValue - the default value for Mapping.map(Object) )} to return when nothing matches the input
    • DomainWildcardMappingBuilder

      public DomainWildcardMappingBuilder(int initialCapacity, V defaultValue)
      Constructor with initial capacity of the map holding the mappings
      Parameters:
      initialCapacity - initial capacity for the internal map
      defaultValue - the default value for Mapping.map(Object) to return when nothing matches the input
  • Method Details

    • add

      public DomainWildcardMappingBuilder<V> add(java.lang.String hostname, V output)
      Adds a mapping that maps the specified (optionally wildcard) host name to the specified output value. null values are forbidden for both hostnames and values.

      DNS wildcard is supported as hostname. The wildcard will only match one sub-domain deep and only when wildcard is used as the most-left label. For example:

      *.netty.io will match xyz.netty.io but NOT abc.xyz.netty.io

      Parameters:
      hostname - the host name (optionally wildcard)
      output - the output value that will be returned by Mapping.map(Object) when the specified host name matches the specified input host name
    • normalizeHostName

      private java.lang.String normalizeHostName(java.lang.String hostname)
    • build

      public Mapping<java.lang.String, V> build()
      Creates a new instance of an immutable Mapping.
      Returns:
      new Mapping instance