Skip to content

Commit 4491278

Browse files
committed
some more documentation for Answer class
1 parent 3e7cacd commit 4491278

File tree

1 file changed

+56
-2
lines changed
  • src/main/java/net/b07z/sepia/server/core/data

1 file changed

+56
-2
lines changed

src/main/java/net/b07z/sepia/server/core/data/Answer.java

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@
1414

1515
import org.json.simple.JSONObject;
1616

17+
/**
18+
* This class contains all required info for answers given by the assistant.
19+
* Answers can have a number of parameters like character (neutral, cool, ...), when to trigger (first time, first repetition, etc.)
20+
* and many more. If you create a custom answer pool (e.g. inside a service) use this constructor to get a good set of parameters:<br>
21+
* Answer(Language language, String type, String text, Character character, int repetition, int mood)
22+
*
23+
* @author Florian Quirin
24+
*
25+
*/
1726
public class Answer {
1827

1928
//database types to organize commands
@@ -42,26 +51,61 @@ public class Answer {
4251
private Map<String, Object> data; //any additional data we did not think of right now
4352
private String date;
4453

54+
/**
55+
* Every answer can be assigned to a certain assistant 'character' like 'cool' or 'rude' (or 'neutral').
56+
*/
4557
public enum Character {
4658
neutral, rude, cool, polite
4759
}
4860

61+
/**
62+
* Usually you want to use another constructor: {@link Answer}(Language language, String type, String text, Character character, int repetition, int mood)
63+
*/
4964
public Answer() {
5065
// needed for Jackson
5166
}
5267

68+
/**
69+
* Create an answer with default settings.
70+
* @param language - language code for this answer
71+
* @param type - answer key, basically an ID to find an answer in the pool
72+
* @param text - actual answer (variables like &lt1&gt, &lt2&gt ... are supported)
73+
*/
5374
public Answer(Language language, String type, String text) {
5475
this(language, type, text, Character.neutral);
5576
}
56-
77+
/**
78+
* Create an answer with default settings and custom character.
79+
* @param language - language code for this answer
80+
* @param type - answer key, basically an ID to find an answer in the pool
81+
* @param text - actual answer (variables like &lt1&gt, &lt2&gt ... are supported)
82+
* @param character - answer {@link Character} like "neutral", "rude", "cool"
83+
*/
5784
public Answer(Language language, String type, String text, Character character) {
5885
this(language, type, text, character, 0, 5);
5986
}
6087

88+
/**
89+
* Build a new answer with all relevant information.
90+
* @param language - language code for this answer
91+
* @param type - answer key, basically an ID to find an answer in the pool
92+
* @param text - actual answer (variables like &lt1&gt, &lt2&gt ... are supported)
93+
* @param character - answer {@link Character} like "neutral", "rude", "cool"
94+
* @param repetition - when will this answer be triggered? First try (0), first repeat (1), following repeats (2)
95+
* @param mood - mood level that this answer will be used from 0-10. Sad (0), neutral (5), happy (10)
96+
*/
6197
public Answer(Language language, String type, String text, Character character, int repetition, int mood) {
6298
this(language, type, text, Collections.singletonList(character), repetition, mood);
6399
}
64-
100+
/**
101+
* Build a new answer with all relevant information.
102+
* @param language - language code for this answer
103+
* @param type - answer key, basically an ID to find an answer in the pool
104+
* @param text - actual answer (variables like &lt1&gt, &lt2&gt ... are supported)
105+
* @param characters - multiple answer {@link Character} like "neutral", "rude", "cool"
106+
* @param repetition - when will this answer be triggered? First try (0), first repeat (1), following repeats (2)
107+
* @param mood - mood level that this answer will be used from 0-10. Sad (0), neutral (5), happy (10)
108+
*/
65109
public Answer(Language language, String type, String text, List<Character> characters, int repetition, int mood) {
66110
this(language, type, text, characters, repetition, mood,
67111
ConfigDefaults.defaultAssistantUserId, Defaults.IMPORT_SOURCE, true, false, false, null,
@@ -70,6 +114,7 @@ public Answer(Language language, String type, String text, List<Character> chara
70114
}
71115

72116
/**
117+
* Usually you want to use another constructor: {@link Answer}(Language language, String type, String text, Character character, int repetition, int mood)
73118
* @param isPublic is this visible for everybody, if not, it's a private answer
74119
* @param isLocal is this run on the local home server?
75120
*/
@@ -101,14 +146,23 @@ public Answer(Language language, String type, String text, List<Character> chara
101146
this.date = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss").format(new Date());
102147
}
103148

149+
/**
150+
* Language in use for this answer.
151+
*/
104152
public Language getLanguage() {
105153
return language;
106154
}
107155

156+
/**
157+
* This is the answer key, basically an ID to find an answer or list of answers in the pool (DB, file or memory).
158+
*/
108159
public String getType() {
109160
return type;
110161
}
111162

163+
/**
164+
* The actual answer in the given language.
165+
*/
112166
public String getText() {
113167
return text;
114168
}

0 commit comments

Comments
 (0)