# Class SetProperty<T,K>

java.lang.Object
com.codename1.properties.PropertyBase<T,K>
com.codename1.properties.CollectionProperty<T,K>
com.codename1.properties.SetProperty<T,K>

All Implemented Interfaces:
  `Iterable<T>`

public class SetProperty<T,K> extends CollectionProperty<T,K>
Base class for a property as a set which can contain multiple elements within

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SetProperty(String name)`
  Constructs a property with null value
  `SetProperty(String name, Class<T> elementType, T... values)`
  Constructs a property with the given name and values by specifying the type of the elements explicitly.
  `SetProperty(String name, T... values)`
  Constructs a property with the given name and value

- ## Method Summary

  Modifier and Type
  Method
  Description
  `K`
  `add(T v)`
  Adds a property value to the set and fires a change event if it changed the set
  `K`
  `addAll(Collection<? extends T> v)`
  Adds a collection of values to the set and fires a change event if it changed the set
  `List<Object>`
  `asExplodedList()`
  Returns a copy of the content as a new list but if the value is a PropertyBusinessObject it will be converted to a Map
  `List<T>`
  `asList()`
  Returns a copy of the content as a new list
  `void`
  `clear()`
  Remove all the elements from the set and fires a change event if the set wasn't empty
  `boolean`
  `contains(T element)`
  Returns true if the given element is contained in the set property
  `boolean`
  `equals(Object obj)`
  Compares this property to another property
  `int`
  `hashCode()`
  Returns the internal hashcode or 0 for null property
  `Iterator<T>`
  `iterator()`
  Iterate over the elements of the property
  `K`
  `remove(int v)`
  Removes the given item from the set and fires a change event if this item has been successfully removed
  `K`
  `remove(T v)`
  Removes the given item from the set and fires a change event if this item has been successfully removed
  `K`
  `removeAll(Collection<? extends T> v)`
  Removes from the set all values from the given collection and fires a change event if the set has changed
  `K`
  `set(Collection<T> t)`
  Sets the entire content of the property
  `int`
  `size()`
  The size of the property set

  ### Methods inherited from class PropertyBase

  `addChangeListener, bindGlobalGetListener, bindGlobalSetListener, firePropertyChanged, getClientProperty, getGenericType, getLabel, getName, putClientProperty, removeChangeListener, setLabel, stopListening, toString, validateCollectionType`

  ### Methods inherited from class Object

  `clone, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface Iterable

  `forEach`

- ## Constructor Details

  - ### SetProperty

    public SetProperty(String name, T... values)

    Constructs a property with the given name and value

    ###### Parameters

    - `name`: the name of the property

    - `values`: default values for the property

  - ### SetProperty

    public SetProperty(String name, Class<T> elementType, T... values)

    Constructs a property with the given name and values by specifying the type of the elements explicitly. The element type needs to be specified if the set should contain `PropertyBusinessObject`s and needs to get deserialized properly!

    ###### Parameters

    - `name`: the name of the property

    - `elementType`: subclass of `PropertyBusinessObject`

    - `values`: default values for the property

  - ### SetProperty

    public SetProperty(String name)

    Constructs a property with null value

    ###### Parameters

    - `name`: the name of the property

- ## Method Details

  - ### size

    public int size()

    The size of the property set

    ###### Returns

    the number of elements

    Specified by:
      `size` in class `CollectionProperty<T,K>`

  - ### set

    public K set(Collection<T> t)

    Sets the entire content of the property

    ###### Parameters

    - `t`: the collection of elements to set

    ###### Returns

    the parent object for chaining

    Specified by:
      `set` in class `CollectionProperty<T,K>`

  - ### add

    public K add(T v)

    Adds a property value to the set and fires a change event if it changed the set

    ###### Parameters

    - `v`: the new value
    Specified by:
      `add` in class `CollectionProperty<T,K>`

  - ### addAll

    public K addAll(Collection<? extends T> v)

    Adds a collection of values to the set and fires a change event if it changed the set

    ###### Parameters

    - `v`: the new value
    Specified by:
      `addAll` in class `CollectionProperty<T,K>`

  - ### remove

    public K remove(T v)

    Removes the given item from the set and fires a change event if this item has been successfully removed

    ###### Parameters

    - `v`: the item to remove
    Specified by:
      `remove` in class `CollectionProperty<T,K>`

  - ### remove

    public K remove(int v)

    Removes the given item from the set and fires a change event if this item has been successfully removed

    ###### Parameters

    - `v`: the item to remove
    Specified by:
      `remove` in class `CollectionProperty<T,K>`

  - ### removeAll

    public K removeAll(Collection<? extends T> v)

    Removes from the set all values from the given collection and fires a change event if the set has changed

    ###### Parameters

    - `the`: item to remove
    Specified by:
      `removeAll` in class `CollectionProperty<T,K>`

  - ### equals

    public boolean equals(Object obj)

    Compares this property to another property

    ###### Parameters

    - `obj`: the other property

    ###### Returns

    true if they are equal in name and value

    Overrides:
      `equals` in class `PropertyBase<T,K>`

  - ### hashCode

    public int hashCode()

    Returns the internal hashcode or 0 for null property

    ###### Returns

    the hashcode value

    Overrides:
      `hashCode` in class `PropertyBase<T,K>`

  - ### iterator

    public Iterator<T> iterator()

    Iterate over the elements of the property

    ###### Returns

    an iterator

    Specified by:
      `iterator` in interface `Iterable<T>`
    Specified by:
      `iterator` in class `CollectionProperty<T,K>`

  - ### asList

    public List<T> asList()

    Returns a copy of the content as a new list

    ###### Returns

    a list

    Specified by:
      `asList` in class `CollectionProperty<T,K>`

  - ### asExplodedList

    public List<Object> asExplodedList()

    Returns a copy of the content as a new list but if the value is a PropertyBusinessObject it will be converted to a Map

    ###### Returns

    a list

    Specified by:
      `asExplodedList` in class `CollectionProperty<T,K>`

  - ### clear

    public void clear()
    Remove all the elements from the set and fires a change event if the set wasn't empty
    Specified by:
      `clear` in class `CollectionProperty<T,K>`

  - ### contains

    public boolean contains(T element)

    Returns true if the given element is contained in the set property

    ###### Parameters

    - `element`: the element

    ###### Returns

    true if the given element is contained in the set property

    Specified by:
      `contains` in class `CollectionProperty<T,K>`