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

Class ConcretePrereqObject

code/src/java/pcgen/cdom/base/ConcretePrereqObject.java:40–261  ·  view source on GitHub ↗

A ConcretePrereqObject is an object that contains a list of Prerequisites. This list of Prerequisites is designed to serve as a list of conditions that must be met before the PrereqObject can be "used" ConcretePrereqObject is intended to provide a quick foundation class that implements PrereqObject

Source from the content-addressed store, hash-verified

38 * implements PrereqObject.
39 */
40public class ConcretePrereqObject implements Cloneable, PrereqObject
41{
42 /** The list of prerequisites */
43 private Set<Prerequisite> thePrereqs = null;
44
45 /**
46 * Returns a List of the Prerequisite objects contained in the PrereqObject.
47 * If the PrereqObject contains no Prerequisites, the return value may be
48 * null or an empty list, it is implementation-specific.
49 *
50 * This method is value-semantic in that ownership of the returned List is
51 * transferred to the class calling this method. Modification of the
52 * returned List will not modify this ConcretePrereqObject and modification
53 * of this ConcretePrereqObject will not modify the returned List.
54 *
55 * @return A List of Prerequisite objects contained in the PrereqObject.
56 */
57 @Override
58 public List<Prerequisite> getPrerequisiteList()
59 {
60 if (thePrereqs == null)
61 {
62 return Collections.emptyList();
63 }
64 return List.copyOf(thePrereqs);
65 }
66
67 /**
68 * Returns true if this object has any prerequisites of the kind that is
69 * passed in.
70 *
71 * @param matchType
72 * The kind of Prerequisite to test for.
73 *
74 * @return <tt>true</tt> if this object has a prerequisite of the kind
75 * that is passed in
76 *
77 * @see pcgen.core.prereq.Prerequisite#getKind()
78 */
79 public final boolean hasPreReqTypeOf(final String matchType)
80 {
81 if (!hasPrerequisites())
82 {
83 return false;
84 }
85
86 return getPrerequisiteList().stream()
87 .anyMatch(prereq -> PrerequisiteUtilities.hasPreReqKindOf(prereq, matchType));
88 }
89
90 /**
91 * Clones this ConcretePrereqObject. This is not a "deep" clone, in that the
92 * List of Prerequisites is cloned (to allow Prerequisites to be
93 * added/removed without altering the original or the clone), but the
94 * Prerequisites contained within the ConcretePrereqObject are not cloned.
95 */
96 @Override
97 public ConcretePrereqObject clone() throws CloneNotSupportedException

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected