Module org.jfree.chart
Package org.jfree.data
Class KeyToGroupMap<K extends Comparable<K>,G extends Comparable<G>>
- java.lang.Object
-
- org.jfree.data.KeyToGroupMap<K,G>
-
- All Implemented Interfaces:
Serializable,Cloneable,PublicCloneable
public class KeyToGroupMap<K extends Comparable<K>,G extends Comparable<G>> extends Object implements Cloneable, PublicCloneable, Serializable
A class that maps keys (instances ofComparable) to groups.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description KeyToGroupMap()Creates a new map with a default group named 'Default Group'.KeyToGroupMap(G defaultGroup)Creates a new map with the specified default group.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()Returns a clone of the map.booleanequals(Object obj)Tests the map for equality against an arbitrary object.GgetGroup(K key)Returns the group that a key is mapped to.intgetGroupCount()Returns the number of groups in the map.intgetGroupIndex(G group)Returns the index for the group.List<G>getGroups()Returns a list of the groups (always including the default group) in the map.intgetKeyCount(G group)Returns the number of keys mapped to the specified group.inthashCode()voidmapKeyToGroup(K key, G group)Maps a key to a group.
-
-
-
Constructor Detail
-
KeyToGroupMap
public KeyToGroupMap()
Creates a new map with a default group named 'Default Group'.
-
KeyToGroupMap
public KeyToGroupMap(G defaultGroup)
Creates a new map with the specified default group.- Parameters:
defaultGroup- the default group (nullnot permitted).
-
-
Method Detail
-
getGroupCount
public int getGroupCount()
Returns the number of groups in the map.- Returns:
- The number of groups in the map.
-
getGroups
public List<G> getGroups()
Returns a list of the groups (always including the default group) in the map. The returned list is independent of the map, so altering the list will have no effect.- Returns:
- The groups (never
null).
-
getGroupIndex
public int getGroupIndex(G group)
Returns the index for the group.- Parameters:
group- the group.- Returns:
- The group index (or -1 if the group is not represented within the map).
-
getGroup
public G getGroup(K key)
Returns the group that a key is mapped to.- Parameters:
key- the key (nullnot permitted).- Returns:
- The group (never
null, returns the default group if there is no mapping for the specified key).
-
mapKeyToGroup
public void mapKeyToGroup(K key, G group)
Maps a key to a group.- Parameters:
key- the key (nullnot permitted).group- the group (nullpermitted, clears any existing mapping).
-
getKeyCount
public int getKeyCount(G group)
Returns the number of keys mapped to the specified group. This method won't always return an accurate result for the default group, since explicit mappings are not required for this group.- Parameters:
group- the group (nullnot permitted).- Returns:
- The key count.
-
clone
public Object clone() throws CloneNotSupportedException
Returns a clone of the map.- Specified by:
clonein interfacePublicCloneable- Overrides:
clonein classObject- Returns:
- A clone.
- Throws:
CloneNotSupportedException- if there is a problem cloning the map.
-
-