# 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`
  Modifier and Type
  Method
  Description
  `void`
  `addChangeListener(PropertyChangeListener<Map.Entry<T,J>, K> pl)`
  Fires a notification that a property value changed to the given listener
  `static void`
  `bindGlobalGetListener(PropertyChangeListener listener)`
  Binds an event callback for get calls and property reads
  `static void`
  `bindGlobalSetListener(PropertyChangeListener listener)`
  Binds an event callback for set calls and property mutation
  `protected void`
  `firePropertyChanged()`
  Delivers the property change event to listeners if applicable
  `Object`
  `getClientProperty(String key)`
  Returns the client property set to this property name
  `Class`
  `getGenericType()`
  Returns the generic type of this property if it is known or null
  `String`
  `getLabel()`
  The label of the property defaults to its name but can be changed to anything
  `String`
  `getName()`
  The property name is immutable and can't be changed after creation it should match the parent field name by convention
  `void`
  `putClientProperty(String key, Object o)`
  Places a property that will apply statically to all instances of this property
  `void`
  `removeChangeListener(PropertyChangeListener<Map.Entry<T,J>, K> pl)`
  Removes the property change listener from the list of listeners
  `void`
  `setLabel(String label)`
  The label of the property defaults to its name but can be changed to anything, it can be used when binding a property to UI elements
  `void`
  `stopListening()`
  This method will work when invoked from a propertyChanged callback and should be similar to `removePropertyChangeListener(this)`.
  `String`
  `toString()`
  Default toString that provides easier debug information
  `protected final void`
  `validateCollectionType(Class elementType)`
  Validates that the collection type is valid and throws an exception otherwise

  ### Methods inherited from class Object

  `clone, getClass, notify, notifyAll, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  `final Class`
  `getClass()`
  Returns the runtime class of an object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `final void`
  `wait()`
  Causes current thread to wait until another thread invokes the method or the method for this object.
  `final void`
  `wait(long timeout)`
  Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
  `final void`
  `wait(long timeout, int nanos)`
  Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

- ## 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>`
    Returns:
      An `Iterator` instance.

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