# Class MapProperty<T,J,K>

java.lang.Object
com.codename1.properties.PropertyBase<Map.Entry<T,J>, K>
com.codename1.properties.MapProperty<T,J,K>

All Implemented Interfaces:
  `Iterable<Map.Entry<T,J>>`

public class MapProperty<T,J,K> extends PropertyBase<Map.Entry<T,J>, K> implements Iterable<Map.Entry<T,J>>
Base class for a property as a Map which can contain multiple elements within it

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MapProperty(String name)`
  Constructs a property with the given name
  `MapProperty(String name, Class genericTypeKey, Class genericTypeValue)`
  Constructs a property with the given name

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Map<T,Object>`
  `asExplodedMap()`
  Returns a copy of the content as a new map but if the value is a PropertyBusinessObject it will be converted to a Map
  `Map<T,J>`
  `asMap()`
  Returns a copy of the content as a new map
  `void`
  `clear()`
  Remove all the elements from the map
  `boolean`
  `equals(Object obj)`
  Compares this property to another property
  `J`
  `get(T key)`
  Gets the property value
  `Class`
  `getKeyType()`
  Returns the class for the key element if it's defined or null if it isn't
  `Class`
  `getValueType()`
  Returns the class for the value element if it's defined or null if it isn't
  `int`
  `hashCode()`
  Returns the internal hashcode or 0 for null property
  `Iterator<Map.Entry<T,J>>`
  `iterator()`
  Iterate over the elements of the property
  `Set<T>`
  `keySet()`
  Returns the set of keys in the map property
  `K`
  `put(T key, J v)`
  Same as `java.lang.Object)` here for coding convention convenience with map code
  `K`
  `remove(T key)`
  Removes the item matching the given key
  `K`
  `set(T key, J v)`
  Sets the property value and potentially fires a change event
  `K`
  `setMap(Map<T,J> t)`
  Sets the entire content of the property
  `int`
  `size()`
  The size of the property list
  `Collection<J>`
  `valueSet()`
  Returns the set of values in the map property

  ### 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`

- ## Constructor Details

  - ### MapProperty

    public MapProperty(String name)

    Constructs a property with the given name

    ###### Parameters

    - `name`: the name of the property

  - ### MapProperty

    public MapProperty(String name, Class genericTypeKey, Class genericTypeValue)

    Constructs a property with the given name

    ###### Parameters

    - `name`: the name of the property

    - `genericTypeKey`: the generic type of the key

    - `genericTypeValue`: the generic type of the value

- ## Method Details

  - ### getKeyType

    public Class getKeyType()

    Returns the class for the key element if it's defined or null if it isn't

    ###### Returns

    the class matching the map key

  - ### getValueType

    public Class getValueType()

    Returns the class for the value element if it's defined or null if it isn't

    ###### Returns

    the class matching the map value

  - ### get

    public J get(T key)

    Gets the property value

    ###### Parameters

    - `key`: the map key

    ###### Returns

    the property value

  - ### size

    public int size()

    The size of the property list

    ###### Returns

    the number of elements

  - ### set

    public K set(T key, J v)

    Sets the property value and potentially fires a change event

    ###### Parameters

    - `key`: the key to set

    - `v`: the new value

  - ### put

    public K put(T key, J v)

    Same as `java.lang.Object)` here for coding convention convenience with map code

    ###### Parameters

    - `key`: the key to set

    - `v`: the new value

  - ### remove

    public K remove(T key)

    Removes the item matching the given key

    ###### Parameters

    - `key`: the key

  - ### 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<Map.Entry<T,J>, K>`

  - ### hashCode

    public int hashCode()

    Returns the internal hashcode or 0 for null property

    ###### Returns

    the hashcode value

    Overrides:
      `hashCode` in class `PropertyBase<Map.Entry<T,J>, K>`

  - ### iterator

    public Iterator<Map.Entry<T,J>> iterator()

    Iterate over the elements of the property

    ###### Returns

    an iterator

    Specified by:
      `iterator` in interface `Iterable<T>`

  - ### keySet

    public Set<T> keySet()

    Returns the set of keys in the map property

    ###### Returns

    the keys

  - ### valueSet

    public Collection<J> valueSet()

    Returns the set of values in the map property

    ###### Returns

    the values

  - ### asMap

    public Map<T,J> asMap()

    Returns a copy of the content as a new map

    ###### Returns

    a map

  - ### asExplodedMap

    public Map<T,Object> asExplodedMap()

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

    ###### Returns

    a map

  - ### setMap

    public K setMap(Map<T,J> t)

    Sets the entire content of the property

    ###### Parameters

    - `t`: the map of elements to set

    ###### Returns

    the parent object for chaining

  - ### clear

    public void clear()
    Remove all the elements from the map