Skip to content

Commit e94783f

Browse files
committed
Updates javadocs
1 parent 7bc8f41 commit e94783f

File tree

6 files changed

+91
-15
lines changed

6 files changed

+91
-15
lines changed

src/test/java/org/json/junit/JSONObjectTest.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2590,6 +2590,9 @@ public void toMap() {
25902590
assertTrue("Map should have 2 elements", map.size() == 2);
25912591
}
25922592

2593+
/**
2594+
* test that validates a singleton can be serialized as a bean.
2595+
*/
25932596
@Test
25942597
public void testSingletonBean() {
25952598
final JSONObject jo = new JSONObject(Singleton.getInstance());
@@ -2609,6 +2612,10 @@ public void testSingletonBean() {
26092612
assertEquals(0, jo.get("someInt"));
26102613
assertEquals(null, jo.opt("someString"));
26112614
}
2615+
2616+
/**
2617+
* test that validates a singleton can be serialized as a bean.
2618+
*/
26122619
@Test
26132620
public void testSingletonEnumBean() {
26142621
final JSONObject jo = new JSONObject(SingletonEnum.getInstance());
@@ -2629,6 +2636,9 @@ public void testSingletonEnumBean() {
26292636
assertEquals(null, jo.opt("someString"));
26302637
}
26312638

2639+
/**
2640+
* Test to validate that a generic class can be serialized as a bean.
2641+
*/
26322642
@Test
26332643
public void testGenericBean() {
26342644
GenericBean<Integer> bean = new GenericBean<>(42);
@@ -2640,6 +2650,9 @@ public void testGenericBean() {
26402650
assertEquals(0, bean.genericSetCounter);
26412651
}
26422652

2653+
/**
2654+
* Test to validate that a generic class can be serialized as a bean.
2655+
*/
26432656
@Test
26442657
public void testGenericIntBean() {
26452658
GenericBeanInt bean = new GenericBeanInt(42);
@@ -2651,6 +2664,9 @@ public void testGenericIntBean() {
26512664
assertEquals(0, bean.genericSetCounter);
26522665
}
26532666

2667+
/**
2668+
* Test to verify <code>key</code> limitations in the JSONObject bean serializer.
2669+
*/
26542670
@Test
26552671
public void testWierdListBean() {
26562672
WeirdList bean = new WeirdList(42, 43, 44);
@@ -2660,7 +2676,8 @@ public void testWierdListBean() {
26602676
// getInt(int) should also be ignored based on parameter count
26612677
// add(Integer) should be ignore as it doesn't start with get/is and also has a parameter
26622678
// getALL should be mapped
2663-
assertEquals("Expected 1 key to mapped "+jo.keySet().toString(), 1, jo.length());
2679+
assertEquals("Expected 1 key to be mapped. Instead found: "+jo.keySet().toString(),
2680+
1, jo.length());
26642681
assertNotNull(jo.get("ALL"));
26652682
}
26662683
}

src/test/java/org/json/junit/data/GenericBean.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
* generic number value
1111
*/
1212
public class GenericBean<T extends Number & Comparable<T>> implements MyBean {
13+
/**
14+
* @param genericValue
15+
* value to initiate with
16+
*/
1317
public GenericBean(T genericValue) {
1418
super();
1519
this.genericValue = genericValue;
@@ -28,7 +32,10 @@ public T getGenericValue() {
2832
return this.genericValue;
2933
}
3034

31-
/** sets the generic value */
35+
/**
36+
* @param genericValue
37+
* generic value to set
38+
*/
3239
public void setGenericValue(T genericValue) {
3340
this.genericSetCounter++;
3441
this.genericValue = genericValue;

src/test/java/org/json/junit/data/GenericBeanInt.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,24 @@ public class GenericBeanInt extends GenericBean<Integer> {
1111
/** */
1212
final char a = 'A';
1313

14-
/** return the a */
14+
/** @return the a */
1515
public char getA() {
1616
return a;
1717
}
18-
19-
/** return false. should not be beanable */
18+
19+
/**
20+
* Should not be beanable
21+
*
22+
* @return false
23+
*/
2024
public boolean getable() {
2125
return false;
2226
}
2327

24-
/** */
28+
/**
29+
* @param genericValue
30+
* the value to initiate with.
31+
*/
2532
public GenericBeanInt(Integer genericValue) {
2633
super(genericValue);
2734
}

src/test/java/org/json/junit/data/Singleton.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,12 @@ public int getSomeInt() {
3636
return someInt;
3737
}
3838

39-
/** sets someInt */
39+
/**
40+
* sets someInt.
41+
*
42+
* @param someInt
43+
* the someInt to set
44+
*/
4045
public void setSomeInt(int someInt) {
4146
this.someInt = someInt;
4247
}
@@ -46,7 +51,12 @@ public String getSomeString() {
4651
return someString;
4752
}
4853

49-
/** sets someString */
54+
/**
55+
* sets someString.
56+
*
57+
* @param someString
58+
* the someString to set
59+
*/
5060
public void setSomeString(String someString) {
5161
this.someString = someString;
5262
}

src/test/java/org/json/junit/data/SingletonEnum.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*
88
*/
99
public enum SingletonEnum {
10+
/**
11+
* the singleton instance.
12+
*/
1013
INSTANCE;
1114
/** */
1215
private int someInt;
@@ -32,7 +35,12 @@ public int getSomeInt() {
3235
return someInt;
3336
}
3437

35-
/** sets someInt */
38+
/**
39+
* sets someInt.
40+
*
41+
* @param someInt
42+
* the someInt to set
43+
*/
3644
public void setSomeInt(int someInt) {
3745
this.someInt = someInt;
3846
}
@@ -42,7 +50,12 @@ public String getSomeString() {
4250
return someString;
4351
}
4452

45-
/** sets someString */
53+
/**
54+
* sets someString.
55+
*
56+
* @param someString
57+
* the someString to set
58+
*/
4659
public void setSomeString(String someString) {
4760
this.someString = someString;
4861
}

src/test/java/org/json/junit/data/WeirdList.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,53 @@ public class WeirdList {
1414
/** */
1515
private final List<Integer> list = new ArrayList<>();
1616

17+
/**
18+
* @param vals
19+
*/
1720
public WeirdList(Integer... vals) {
1821
this.list.addAll(Arrays.asList(vals));
1922
}
2023

21-
/** gets a copy of the list */
24+
/**
25+
* @return a copy of the list
26+
*/
2227
public List<Integer> get() {
2328
return new ArrayList<>(this.list);
2429
}
2530

26-
/** gets a copy of the list */
31+
/**
32+
* @return a copy of the list
33+
*/
2734
public List<Integer> getALL() {
2835
return new ArrayList<>(this.list);
2936
}
3037

31-
/** get an index */
38+
/**
39+
* get a value at an index.
40+
*
41+
* @param i
42+
* index to get
43+
* @return the value at the index
44+
*/
3245
public Integer get(int i) {
3346
return this.list.get(i);
3447
}
3548

36-
/** get an index */
49+
/**
50+
* get a value at an index.
51+
*
52+
* @param i
53+
* index to get
54+
* @return the value at the index
55+
*/
3756
public int getInt(int i) {
3857
return this.list.get(i);
3958
}
4059

41-
/** adds a new value to the end of the list */
60+
/**
61+
* @param value
62+
* new value to add to the end of the list
63+
*/
4264
public void add(Integer value) {
4365
this.list.add(value);
4466
}

0 commit comments

Comments
 (0)