source: TraumaOntologies/src/main/java/tudelft/healthpsychology/traumaontologies/answerstate/AnswerState.java

Last change on this file was 5, checked in by Bart Vastenhouw, 5 years ago

Intermediate update

File size: 2.7 KB
Line 
1package tudelft.healthpsychology.traumaontologies.answerstate;
2
3import java.util.Collection;
4
5import com.fasterxml.jackson.annotation.JsonAutoDetect;
6import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
7import com.fasterxml.jackson.annotation.JsonSubTypes;
8import com.fasterxml.jackson.annotation.JsonTypeInfo;
9
10import tudelft.healthpsychology.traumaontologies.questiontypes.TypedQuestion;
11import tudelft.utilities.tree.Tree;
12
13/**
14 * <o> Defines (possibly partial) answer to a question and the answer type
15 * needed to bring it closer to a full answer. An AnswerState contains
16 * references to node labels in a {@link Tree}. The tree structure
17 * (children/parent relations, node labels and node attributes) contains the
18 * detailed information for the answerstate on how to proceed.
19 * </p>
20 * <o> All {@link AnswerState}s work like this: provide answers (just a string)
21 * to all the questions until there are no more questions.
22 * </p>
23 * <o> To get the next question, call {@link #getOptions()} which gives you the
24 * question and the allowed answers. Call {@link #with(String)} with the answer
25 * string and update to the returned state. Repeat until {@link #getOptions()}
26 * returns null.
27 * </p>
28 * <o> All AnswerState implementations are immutable,
29 * </p>
30 */
31@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
32@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT)
33@JsonSubTypes({ @JsonSubTypes.Type(value = AnswersBreathFirstState.class),
34 @JsonSubTypes.Type(value = AnswersDepthFirstState.class),
35 @JsonSubTypes.Type(value = AnswerStateExplanationDecorator.class),
36 @JsonSubTypes.Type(value = ListOfAnswersState.class),
37 @JsonSubTypes.Type(value = OntoPropAnswerState.class),
38 @JsonSubTypes.Type(value = PropertiesAnswerState.class) })
39public interface AnswerState {
40
41 /**
42 * @param tree the tree containing the node(s) relevant for this state.
43 * @return the type of the possible answer(s). null if this is the final
44 * state.
45 */
46 TypedQuestion getOptions(
47 Tree<String, Collection<Property>, OntologyNode> tree);
48
49 /**
50 *
51 * @param answer the next answer. In some cases "null" is accepted, as the
52 * "other", "not applicable" or "don't know" option.
53 * @param tree the tree containing the node(s) relevant for this state.
54 * @return a new state representing the situation after the answer was given
55 * @throws IllegalArgumentException if the given answer does not fit : see
56 * {@link TypedQuestion#fits(String)}
57 */
58 AnswerState with(String answer,
59 Tree<String, Collection<Property>, OntologyNode> tree);
60
61}
Note: See TracBrowser for help on using the repository browser.