inet.ipaddr

Class IPAddressNetwork.HostIDStringAddressGenerator<T extends HostIdentifierString>

  • java.lang.Object
    • inet.ipaddr.IPAddressNetwork.HostIDStringAddressGenerator<T>
  • Type Parameters:
    T - the type to be cached, typically either IPAddressString or HostName
    All Implemented Interfaces:
    java.io.Serializable
    Enclosing class:
    IPAddressNetwork<T extends IPAddress,R extends IPAddressSection,E extends IPAddressSection,S extends IPAddressSegment,J extends java.net.InetAddress>


    public abstract static class IPAddressNetwork.HostIDStringAddressGenerator<T extends HostIdentifierString>
    extends java.lang.Object
    implements java.io.Serializable
    Choose a map of your choice to implement a cache of addresses and/or host names.

    You can also use this class without a cache to serve as a factory of addresses or host names, which can be particularly useful if you are using your own network, or if you are using your own validation options.

    For long-running programs or servers that handle many addresses, the benefits of using a cache are that

    • the lookup can provide the same objects for different strings that identify the same host name or address
    • parsing and resolving repeated instances of the same address or host string is minimized. Both IPAddressString and HostName cache their parsed and resolved addresses.
    • other functionality is optimized through caching, since Host Name, IPAddressString, and IPAddress also caches objects such as generated strings. With cached objects, switching between host names, address strings and numeric addresses is constant time.

    You choose the map of your choice to be the backing map for the cache. For example, for thread-safe access to the cache, ConcurrentHashMap is a good choice. For maps of bounded size, LinkedHashMap provides the removeEldestEntry method to override to implement LRU or other eviction mechanisms.

    See Also:
    Serialized Form