1
0
Fork 0
mirror of https://github.com/ethauvin/JSON-java.git synced 2025-06-17 16:00:51 -07:00

Adds new tests for testing bean->JSONObject mapping

This commit is contained in:
John J. Aylward 2017-07-09 17:35:46 -04:00
parent 0e3f23d7a1
commit 49117f33dc
6 changed files with 356 additions and 0 deletions

View file

@ -0,0 +1,72 @@
package org.json.junit.data;
import java.io.StringReader;
/**
*
* @author John Aylward
*
* @param <T>
* generic number value
*/
public class GenericBean<T extends Number & Comparable<T>> implements MyBean {
public GenericBean(T genericValue) {
super();
this.genericValue = genericValue;
}
/** */
private T genericValue;
/** to be used by the calling test to see how often the getter is called */
public int genericGetCounter;
/** to be used by the calling test to see how often the setter is called */
public int genericSetCounter;
/** @return the genericValue */
public T getGenericValue() {
this.genericGetCounter++;
return this.genericValue;
}
/** sets the generic value */
public void setGenericValue(T genericValue) {
this.genericSetCounter++;
this.genericValue = genericValue;
}
@Override
public Integer getIntKey() {
return Integer.valueOf(42);
}
@Override
public Double getDoubleKey() {
return Double.valueOf(4.2);
}
@Override
public String getStringKey() {
return "MyString Key";
}
@Override
public String getEscapeStringKey() {
return "\"My String with \"s";
}
@Override
public Boolean isTrueKey() {
return Boolean.TRUE;
}
@Override
public Boolean isFalseKey() {
return Boolean.FALSE;
}
@Override
public StringReader getStringReaderKey() {
return new StringReader("Some String Value in a reader");
}
}