Class Container<T>

  • Type Parameters:
    T - the type of the item in this container.

    @NotThreadSafe
    public class Container<T>
    extends Object
    Generic container of items of any type.

    This class is not thread-safe, if thread safety is required it should be done externally to the class.

    The author believes he borrowed the idea for such a class many years ago from a man called Boris Karadjov.

    Version:
    2016-10-13
    Author:
    Dimitar A. Stoikov
    • Constructor Detail

      • Container

        public Container()
        Creates a new container with no item.
      • Container

        public Container​(T item)
        Creates a new container with the specified item.
        Parameters:
        item - The item, may be null.
    • Method Detail

      • get

        public T get()
        Gets the contained item.
        Returns:
        The item, null if none.
      • set

        public void set​(T item)
        Sets the contained item.
        Parameters:
        item - The item, may be null.