MCPcopy Create free account
hub / github.com/PCGen/pcgen / delEquipSet

Method delEquipSet

code/src/java/pcgen/cdom/facet/EquipSetFacet.java:46–74  ·  view source on GitHub ↗

Remove an EqSet from the PC's Equipped Equipment. @param id The identifier of the PC @param eSet The EquipSet to remove. @return true if the object was removed.

(CharID id, EquipSet eSet)

Source from the content-addressed store, hash-verified

44 * @return true if the object was removed.
45 */
46 public boolean delEquipSet(CharID id, EquipSet eSet)
47 {
48 Collection<EquipSet> componentSet = getCachedSet(id);
49 if (componentSet == null)
50 {
51 return false;
52 }
53
54 boolean found = false;
55 final String pid = eSet.getIdPath();
56
57 // first remove this EquipSet
58 componentSet.remove(eSet);
59
60 // now find and remove all it's children
61 for (Iterator<EquipSet> e = componentSet.iterator(); e.hasNext();)
62 {
63 final EquipSet es = e.next();
64 final String abParentId = es.getParentIdPath() + Constants.EQUIP_SET_PATH_SEPARATOR;
65 final String abPid = pid + Constants.EQUIP_SET_PATH_SEPARATOR;
66
67 if (abParentId.startsWith(abPid))
68 {
69 e.remove();
70 found = true;
71 }
72 }
73 return found;
74 }
75
76 /**
77 * Search all of the PC equipment sets and replace all instances of oldItem with newItem.

Callers 1

delEquipSetItemMethod · 0.95

Calls 7

getParentIdPathMethod · 0.95
removeMethod · 0.65
getCachedSetMethod · 0.45
getIdPathMethod · 0.45
iteratorMethod · 0.45
hasNextMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected