Skip to content

Commit e3ca748

Browse files
author
Ben McLean
committed
Added documentation to score classes
1 parent 1c07daf commit e3ca748

File tree

5 files changed

+103
-20
lines changed

5 files changed

+103
-20
lines changed

src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public Builder addRequestedAttribute(AttributeType type, RequestedAttribute requ
146146
if(requestedAttribute != null){
147147
requestedAttributes.put(type, requestedAttribute);
148148
}else{
149-
requestedAttributes.put(type, new RequestedAttribute());
149+
requestedAttributes.put(type, new RequestedAttribute.Builder().build());
150150
}
151151
return this;
152152
}

src/au/com/origma/perspectiveapi/v1alpha1/models/RequestedAttribute.java

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,51 +6,66 @@
66
*/
77
package au.com.origma.perspectiveapi.v1alpha1.models;
88

9+
/**
10+
* Represents the parameters of a requested attribute
11+
*
12+
* @author Ben McLean <ben@origma.com.au>
13+
*
14+
*/
915
public class RequestedAttribute {
1016

1117
ScoreType scoreType;
1218
Double scoreThreshold;
1319

14-
public RequestedAttribute() {
15-
super();
16-
}
17-
18-
public RequestedAttribute(ScoreType scoreType, Double scoreThreshold) {
19-
super();
20-
this.scoreType = scoreType;
21-
this.scoreThreshold = scoreThreshold;
22-
}
23-
20+
/**
21+
* Returns the score type of the attribute
22+
* @return the score type of the attribute
23+
*/
2424
public ScoreType getScoreType() {
2525
return scoreType;
2626
}
2727

28-
public void setScoreType(ScoreType scoreType) {
29-
this.scoreType = scoreType;
30-
}
31-
28+
/**
29+
* Returns the score threshold of the attribute
30+
* @return the score threshold of the attribute
31+
*/
3232
public Double getScoreThreshold() {
3333
return scoreThreshold;
3434
}
3535

36-
public void setScoreThreshold(Double scoreThreshold) {
37-
this.scoreThreshold = scoreThreshold;
38-
}
39-
36+
/**
37+
* Builds a RequestedAttribute
38+
*
39+
* @author Ben McLean <ben@origma.com.au>
40+
*/
4041
public static class Builder {
4142
private ScoreType scoreType;
4243
private Double scoreThreshold;
4344

45+
/**
46+
* Sets the score type of the attribute
47+
* @param scoreType the score type of the attribute
48+
* @return The builder
49+
*/
4450
public Builder scoreType(ScoreType scoreType) {
4551
this.scoreType = scoreType;
4652
return this;
4753
}
4854

55+
/**
56+
* Sets the score threshold of the attribute
57+
* @param scoreThreshold the score threshold of the attribute
58+
* @return The builder
59+
*/
4960
public Builder scoreThreshold(Double scoreThreshold) {
5061
this.scoreThreshold = scoreThreshold;
5162
return this;
5263
}
5364

65+
/**
66+
* Builds a new instance of RequestedAttribute
67+
* @return a new instance of RequestedAttribute
68+
*/
5469
public RequestedAttribute build() {
5570
return new RequestedAttribute(this);
5671
}

src/au/com/origma/perspectiveapi/v1alpha1/models/Score.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,58 @@
66
*/
77
package au.com.origma.perspectiveapi.v1alpha1.models;
88

9+
/**
10+
* Represents the value of an analysis attribute
11+
*
12+
* @author Ben McLean <ben@origma.com.au>
13+
*/
914
public class Score {
1015

1116
float value;
1217
ScoreType type;
1318

19+
/**
20+
* Create an empty instance
21+
*/
1422
public Score(){}
1523

24+
/**
25+
* Create an instance
26+
*/
1627
public Score(float value, ScoreType type) {
1728
super();
1829
this.value = value;
1930
this.type = type;
2031
}
2132

33+
/**
34+
* Returns the value of a score
35+
* @return the value of a score
36+
*/
2237
public float getValue() {
2338
return value;
2439
}
2540

41+
/**
42+
* Sets the value of a score
43+
* @param value the value of a score
44+
*/
2645
public void setValue(float value) {
2746
this.value = value;
2847
}
2948

49+
/**
50+
* Returns the type of a score
51+
* @return the type of a score
52+
*/
3053
public ScoreType getType() {
3154
return type;
3255
}
3356

57+
/**
58+
* Sets the type of a score
59+
* @param type the type of a score
60+
*/
3461
public void setType(ScoreType type) {
3562
this.type = type;
3663
}

src/au/com/origma/perspectiveapi/v1alpha1/models/ScoreType.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
*/
77
package au.com.origma.perspectiveapi.v1alpha1.models;
88

9+
/**
10+
* The form a score takes
11+
*
12+
* @author Ben McLean <ben@origma.com.au>
13+
*
14+
*/
915
public enum ScoreType {
1016
PROBABILITY
1117
}

src/au/com/origma/perspectiveapi/v1alpha1/models/SpanScore.java

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,77 @@
55
* Written by Ben McLean <ben@origma.com.au>, November 2019
66
*/
77
package au.com.origma.perspectiveapi.v1alpha1.models;
8-
8+
/**
9+
* A score representing a span of the analyzed comment
10+
*
11+
* @author Ben McLean &lt;ben@origma.com.au&gt;
12+
*
13+
*/
914
public class SpanScore {
1015

1116
int begin;
1217
int end;
1318
Score score;
1419

20+
/**
21+
* Create an empty instance
22+
*/
1523
public SpanScore(){}
1624

25+
/**
26+
* Create an instance
27+
*/
1728
public SpanScore(int begin, int end, Score score) {
1829
super();
1930
this.begin = begin;
2031
this.end = end;
2132
this.score = score;
2233
}
2334

35+
/**
36+
* Returns the beginning position of the span
37+
* @return the beginning position of the span
38+
*/
2439
public int getBegin() {
2540
return begin;
2641
}
2742

43+
/**
44+
* Sets the beginning position of the span
45+
* @param begin the beginning position of the span
46+
*/
2847
public void setBegin(int begin) {
2948
this.begin = begin;
3049
}
3150

51+
/**
52+
* Returns the ending position of the span
53+
* @return the ending position of the span
54+
*/
3255
public int getEnd() {
3356
return end;
3457
}
3558

59+
/**
60+
* Sets the ending position of the span
61+
* @param end the ending position of the span
62+
*/
3663
public void setEnd(int end) {
3764
this.end = end;
3865
}
3966

67+
/**
68+
* Returns the score of the span
69+
* @return the score of the span
70+
*/
4071
public Score getScore() {
4172
return score;
4273
}
4374

75+
/**
76+
* Sets the score of the span
77+
* @param score the score of the span
78+
*/
4479
public void setScore(Score score) {
4580
this.score = score;
4681
}

0 commit comments

Comments
 (0)