Class ConcreteHostNameData

java.lang.Object
de.calamanari.pk.nullobject.ConcreteHostNameData
All Implemented Interfaces:
HostNameData, java.io.Serializable, java.lang.Iterable<java.lang.String>

public class ConcreteHostNameData
extends java.lang.Object
implements HostNameData
Concrete Host Name Data - a real host name data implementation
Author:
Karl Eilebrecht
See Also:
Serialized Form
  • Constructor Summary

    Constructors
    Constructor Description
    ConcreteHostNameData​(java.lang.String purpose)
    Creates new data object
    ConcreteHostNameData​(java.lang.String purpose, java.util.Collection<java.lang.String> names)
    Creates new instance from the given list and purpose
  • Method Summary

    Modifier and Type Method Description
    boolean addHostName​(java.lang.String e)
    Adds the name to the list
    boolean contains​(java.lang.String name)
    Returns whether this list contains the name
    boolean containsAll​(java.util.Collection<? extends java.lang.String> coll)
    Returns whether the list contains all of the given names
    <T extends HostNameData>
    T
    copy()
    Creates a copy of this object, so that the internal state of the copy will be independent.
    This is not a deep clone as the values will not be copied but referenced.
    java.lang.String get​(int index)
    Returns the name at the given position
    int getNumberOfEntries()
    Returns the number of entries in host name data
    java.lang.String getPurpose()
    returns the purpose (whatever this might be :-) )
    int indexOf​(java.lang.String name)
    Returns the position of the given entry
    java.util.Iterator<java.lang.String> iterator()  
    java.lang.String[] toArray()
    Returns an array with all the names from the list

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • ConcreteHostNameData

      public ConcreteHostNameData​(java.lang.String purpose)
      Creates new data object
      Parameters:
      purpose - what this instance is for
    • ConcreteHostNameData

      public ConcreteHostNameData​(java.lang.String purpose, java.util.Collection<java.lang.String> names)
      Creates new instance from the given list and purpose
      Parameters:
      purpose - data purpose
      names - collection of names, may be null
  • Method Details

    • getPurpose

      public java.lang.String getPurpose()
      Description copied from interface: HostNameData
      returns the purpose (whatever this might be :-) )
      Specified by:
      getPurpose in interface HostNameData
      Returns:
      purpose of list
    • getNumberOfEntries

      public int getNumberOfEntries()
      Description copied from interface: HostNameData
      Returns the number of entries in host name data
      Specified by:
      getNumberOfEntries in interface HostNameData
      Returns:
      number of entries
    • contains

      public boolean contains​(java.lang.String name)
      Description copied from interface: HostNameData
      Returns whether this list contains the name
      Specified by:
      contains in interface HostNameData
      Parameters:
      name - the host name to look for
      Returns:
      true if found
    • indexOf

      public int indexOf​(java.lang.String name)
      Description copied from interface: HostNameData
      Returns the position of the given entry
      Specified by:
      indexOf in interface HostNameData
      Parameters:
      name - the host name to look for
      Returns:
      true if found otherwise -1
    • containsAll

      public boolean containsAll​(java.util.Collection<? extends java.lang.String> coll)
      Description copied from interface: HostNameData
      Returns whether the list contains all of the given names
      Specified by:
      containsAll in interface HostNameData
      Parameters:
      coll - collection of names to look for
      Returns:
      true if all names of the given list where found in this list
    • toArray

      public java.lang.String[] toArray()
      Description copied from interface: HostNameData
      Returns an array with all the names from the list
      Specified by:
      toArray in interface HostNameData
      Returns:
      array of names
    • get

      public java.lang.String get​(int index)
      Description copied from interface: HostNameData
      Returns the name at the given position
      Specified by:
      get in interface HostNameData
      Parameters:
      index - position
      Returns:
      name at the given index or null if not found
    • addHostName

      public boolean addHostName​(java.lang.String e)
      Description copied from interface: HostNameData
      Adds the name to the list
      Specified by:
      addHostName in interface HostNameData
      Parameters:
      e - host name
      Returns:
      true if the name was added, false otherwise
    • iterator

      public java.util.Iterator<java.lang.String> iterator()
      Specified by:
      iterator in interface java.lang.Iterable<java.lang.String>
    • copy

      public <T extends HostNameData> T copy()
      Creates a copy of this object, so that the internal state of the copy will be independent.
      This is not a deep clone as the values will not be copied but referenced.
      Specified by:
      copy in interface HostNameData
      Type Parameters:
      T - expected concrete class implementing HostNameData
      Returns:
      copy of this object