|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object standup.joke.JokeConstraints
public class JokeConstraints
Field Summary | |
---|---|
private Set<JokeConstraint> |
constraints
|
Constructor Summary | |
---|---|
JokeConstraints()
|
Method Summary | |
---|---|
void |
add(JokeConstraint c)
|
void |
add(JokeConstraints cs)
|
boolean |
equals(Object obj)
|
private List<SchemaTemplatePair> |
filterSTPs(List<SchemaTemplatePair> existingSTPs,
JokeConstraintType jc)
Returns the intersection between existingSTPs , a list of
SchemaTemplatePair s, and jc , a
JokeConstraintType . |
Collection<JokeConstraint> |
getConstraints()
|
InstantiationConstraint[] |
getInstantiationConstraints()
Takes all the InstantiationConstraint s in this
JokeConstraints and returns them as an
InstantiationConstraint[] array. |
List<SchemaTemplatePair> |
getSchemaTemplatePairs(JokeType masterType)
Takes all the JokeConstraintType s and
JokeConstraintAllowedSchemas in this JokeConstraints and
returns a List of all the possible
SchemaTemplatePair s that satisfy all of them. |
int |
hashCode()
|
boolean |
isEmpty()
|
void |
remove(JokeConstraint c)
|
void |
remove(JokeConstraints cs)
|
String |
toString()
|
boolean |
validate(JokeStructure j)
This boolean function returns true whether existing JokeStructure j satisfies all the constraints in this JokeConstraints, and false otherwise. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private Set<JokeConstraint> constraints
Constructor Detail |
---|
public JokeConstraints()
Method Detail |
---|
public boolean isEmpty()
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public void add(JokeConstraint c)
public void add(JokeConstraints cs)
public void remove(JokeConstraint c)
public void remove(JokeConstraints cs)
public boolean validate(JokeStructure j)
j
- the JokeStructure being validated
public String toString()
toString
in class Object
public Collection<JokeConstraint> getConstraints()
public InstantiationConstraint[] getInstantiationConstraints()
InstantiationConstraint
s in this
JokeConstraints
and returns them as an
InstantiationConstraint[]
array.
If constraints
is null
or contains no
InstantiationConstraint
s, it simply returns
null
.
InstantiationConstraint
spublic List<SchemaTemplatePair> getSchemaTemplatePairs(JokeType masterType)
Takes all the JokeConstraintType
s and
JokeConstraintAllowedSchemas
in this JokeConstraints
and
returns a List
of all the possible
SchemaTemplatePair
s that satisfy all of them.
It starts with the SchemaTemplatePair
s in the given
JokeType
, which would typically be the master joke type (as
returned by Generator.getMasterJokeType()
, and computes the
valid intersection specified by all the given
JokeConstraintType
s by repeatedly calling
filterSTPs(List, JokeConstraintType)
. If there are no specified
JokeConstraintType
s, it simply returns all the
SchemaTemplatePair
s in the given joke type.
masterType
- the JokeType containing all the SchemaTemplatePairs that will
be used as the starting point
List
of SchemaTemplatePair
s that
satisfy all JokeConstraintType
s in the given
JokeConstraints
private List<SchemaTemplatePair> filterSTPs(List<SchemaTemplatePair> existingSTPs, JokeConstraintType jc)
existingSTPs
, a list of
SchemaTemplatePair
s, and jc
, a
JokeConstraintType
.
The intersection is computed at two levels: that of question and answer
templates. For example, the intersection between
{
and
{
is {
.
existingSTPs
- an existing list of SchemaTemplatePair
sjc
- a JokeConstraintType
existingSTPs
and the
SchemaTemplatePair
s in jc
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |