Package io.netty.util

Class DomainNameMappingBuilder.ImmutableDomainNameMapping<V>

java.lang.Object
io.netty.util.DomainNameMapping<V>
io.netty.util.DomainNameMappingBuilder.ImmutableDomainNameMapping<V>
Type Parameters:
V - concrete type of value objects
All Implemented Interfaces:
Mapping<String,V>
Enclosing class:
DomainNameMappingBuilder<V>

private static final class DomainNameMappingBuilder.ImmutableDomainNameMapping<V> extends DomainNameMapping<V>
Immutable mapping from domain name pattern to its associated value object. Mapping is represented by two arrays: keys and values. Key domainNamePatterns[i] is associated with values[i].
  • Field Details

  • Constructor Details

    • ImmutableDomainNameMapping

      private ImmutableDomainNameMapping(V defaultValue, Map<String,V> map)
  • Method Details

    • add

      @Deprecated public DomainNameMapping<V> add(String hostname, V output)
      Deprecated.
      Description copied from class: DomainNameMapping
      Adds a mapping that maps the specified (optionally wildcard) host name to the specified output value.

      DNS wildcard is supported as hostname. For example, you can use *.netty.io to match netty.io and downloads.netty.io.

      Overrides:
      add in class DomainNameMapping<V>
      Parameters:
      hostname - the host name (optionally wildcard)
      output - the output value that will be returned by DomainNameMapping.map(String) when the specified host name matches the specified input host name
    • map

      public V map(String hostname)
      Description copied from interface: Mapping
      Returns mapped value of the specified input.
      Specified by:
      map in interface Mapping<String,V>
      Overrides:
      map in class DomainNameMapping<V>
    • asMap

      public Map<String,V> asMap()
      Description copied from class: DomainNameMapping
      Returns a read-only Map of the domain mapping patterns and their associated value objects.
      Overrides:
      asMap in class DomainNameMapping<V>
    • toString

      public String toString()
      Overrides:
      toString in class DomainNameMapping<V>
    • estimateBufferSize

      private static int estimateBufferSize(int defaultValueLength, int numberOfMappings, int estimatedMappingLength)
      Estimates the length of string representation of the given instance: est = lengthOfConstantComponents + defaultValueLength + (estimatedMappingLength * numOfMappings) * 1.10
      Parameters:
      defaultValueLength - length of string representation of DomainNameMappingBuilder.defaultValue
      numberOfMappings - number of mappings the given instance holds, e.g.
      invalid @link
      {@link #domainNamePatterns#length
      }
      estimatedMappingLength - estimated size taken by one mapping
      Returns:
      estimated length of string returned by toString()
    • appendMapping

      private StringBuilder appendMapping(StringBuilder sb, int mappingIndex)
    • appendMapping

      private static StringBuilder appendMapping(StringBuilder sb, String domainNamePattern, String value)