Class StringList

All Implemented Interfaces:
Iterable<String>, PrimitiveBeanCollection<String>

public class StringList extends AnchorBean<StringList> implements PrimitiveBeanCollection<String>
A bean defining a list of Strings.

An example:


   <datasets config-class="org.anchoranalysis.bean.primitive.StringList" config-factory="stringList">
 	    <item>first_dataset</item>
 	    <item>second_dataset</item>
 	    <item>some_other_dataset</item>
   </datasets>
 
Author:
Owen Feehan
  • Constructor Details

    • StringList

      public StringList()
      Constructs with an empty list.
    • StringList

      public StringList(String... values)
      Constructs, populated with one or more values.
      Parameters:
      values - the values.
    • StringList

      public StringList(List<String> list)
      Constructs, populated with a list of strings.
      Parameters:
      list - the list.
  • Method Details

    • add

      public void add(String value)
      Description copied from interface: PrimitiveBeanCollection
      Add an element to the collection.
      Specified by:
      add in interface PrimitiveBeanCollection<String>
      Parameters:
      value - the element to add.
    • contains

      public boolean contains(String value)
      Description copied from interface: PrimitiveBeanCollection
      Whether the collection contains a particular element?
      Specified by:
      contains in interface PrimitiveBeanCollection<String>
      Parameters:
      value - the element to search for
      Returns:
      true iff the collection contains the element.
    • iterator

      public Iterator<String> iterator()
      Specified by:
      iterator in interface Iterable<String>
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: PrimitiveBeanCollection
      Whether the collection is empty or not.
      Specified by:
      isEmpty in interface PrimitiveBeanCollection<String>
      Returns:
      true iff the collection contains zero elements.
    • duplicateBean

      public StringList duplicateBean()
      Duplicate the bean.

      NOTE: We need to specifically-implement it as the AnchorBean functionality won't work with this implementation, as it uses non-default initialization (using a config-factory).

      Overrides:
      duplicateBean in class AnchorBean<StringList>
      Returns:
      the newly created bean
    • asList

      public List<String> asList()
      Exposes the underlying list of values.
      Returns:
      the underlying list, which if modified, also modifies this instance.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object