CMCommon
, CMObject
, ItemCollection
, java.lang.Cloneable
, java.lang.Comparable<CMObject>
public class DefaultItemCollection extends java.lang.Object implements ItemCollection, CMCommon
idConverter
Constructor | Description |
---|---|
DefaultItemCollection() |
Modifier and Type | Method | Description |
---|---|---|
void |
addItem(Item item) |
Adds a new item to its possessor.
|
int |
compareTo(CMObject o) |
|
CMObject |
copyOf() |
Similar to Cloneable.clone(), but does its best to make sure that
any internal objects to this class are also copyOfed.
|
void |
delAllItems(boolean destroy) |
Removes all items from this collection
|
void |
delItem(Item item) |
Removes the item from this possessor.
|
void |
eachItem(EachApplicable<Item> applier) |
Applies the given code to each item in this collection
|
Item |
findItem(Item goodLocation,
java.lang.String itemID) |
Returns the item in the given container that matches the
given itemID, whether by full name, description, class ID,
or partial name (if no fuller name is found).
|
Item |
findItem(java.lang.String itemID) |
Returns the item in this possessor that matches the
given itemID, whether by full name, description, class ID,
or partial name (if no fuller name is found).
|
java.util.List<Item> |
findItems(Item goodLocation,
java.lang.String itemID) |
Returns all items in the given container that matches the
given itemID, whether by full name, description, class ID,
or partial name (if no fuller names are found).
|
java.util.List<Item> |
findItems(java.lang.String itemID) |
Returns all items in this possessor that matches the
given itemID, whether by full name, description, class ID,
or partial name (if no fuller names are found).
|
Item |
getItem(int i) |
Returns the item at the given index, regardless of container status,
visibility, or other modifiers.
|
Item |
getRandomItem() |
Returns a random item in this collection, or null
|
java.lang.String |
ID() |
The CoffeeMud Java Class ID shared by all instances of
this object.
|
void |
initializeClass() |
Called ONCE after all objects are loaded, but before the map is read in
during initialization.
|
boolean |
isContent(Item item) |
Returns whether the given item is in this possessors list.
|
java.util.Enumeration<Item> |
items() |
An enumeration of all the items at this possessor.
|
java.lang.String |
name() |
The displayable name of this object.
|
CMObject |
newInstance() |
Returns a new instance of this class.
|
int |
numItems() |
Returns the total number of items at this possessor, regardless
of container status.
|
public java.lang.String ID()
CMObject
public java.lang.String name()
CMObject
name
in interface CMObject
Environmental.Name()
public CMObject copyOf()
CMObject
public void initializeClass()
CMObject
initializeClass
in interface CMObject
public CMObject newInstance()
CMObject
newInstance
in interface CMObject
public int compareTo(CMObject o)
compareTo
in interface java.lang.Comparable<CMObject>
public Item findItem(java.lang.String itemID)
ItemCollection
findItem
in interface ItemCollection
itemID
- the name or partial name of the item to fetchpublic java.util.Enumeration<Item> items()
ItemCollection
items
in interface ItemCollection
public Item findItem(Item goodLocation, java.lang.String itemID)
ItemCollection
findItem
in interface ItemCollection
goodLocation
- the container to look in, or null for noneitemID
- the name or partial name of the item to fetchpublic java.util.List<Item> findItems(Item goodLocation, java.lang.String itemID)
ItemCollection
findItems
in interface ItemCollection
goodLocation
- the container to look in, or null for noneitemID
- the name or partial name of the item to fetchpublic java.util.List<Item> findItems(java.lang.String itemID)
ItemCollection
findItems
in interface ItemCollection
itemID
- the name or partial name of the item to fetchpublic void addItem(Item item)
ItemCollection
addItem
in interface ItemCollection
item
- the item to addItemCollection.delItem(Item)
public void delItem(Item item)
ItemCollection
delItem
in interface ItemCollection
item
- the item to removepublic int numItems()
ItemCollection
numItems
in interface ItemCollection
public boolean isContent(Item item)
ItemCollection
isContent
in interface ItemCollection
item
- the item to checkpublic void delAllItems(boolean destroy)
ItemCollection
delAllItems
in interface ItemCollection
destroy
- true to also destroy the itemspublic void eachItem(EachApplicable<Item> applier)
ItemCollection
eachItem
in interface ItemCollection
applier
- code to execute against each objectpublic Item getItem(int i)
ItemCollection
getItem
in interface ItemCollection
i
- the index of the itempublic Item getRandomItem()
ItemCollection
getRandomItem
in interface ItemCollection