mirror of
https://github.com/stleary/JSON-java.git
synced 2025-08-02 19:15:27 -04:00
tech-debt-25250701 add jacoco to gradle build, refactor JSONObject to restore performance
This commit is contained in:
parent
197afddbfb
commit
7b0d1942b4
14
build.gradle
14
build.gradle
@ -3,9 +3,10 @@
|
|||||||
*/
|
*/
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
// apply plugin: 'jacoco'
|
apply plugin: 'jacoco'
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
|
||||||
|
// for now, publishing to maven is still a manual process
|
||||||
//plugins {
|
//plugins {
|
||||||
// id 'java'
|
// id 'java'
|
||||||
//id 'maven-publish'
|
//id 'maven-publish'
|
||||||
@ -19,6 +20,17 @@ repositories {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To view the report open build/reports/jacoco/test/html/index.html
|
||||||
|
jacocoTestReport {
|
||||||
|
reports {
|
||||||
|
html.required = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
finalizedBy jacocoTestReport
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
testImplementation 'com.jayway.jsonpath:json-path:2.9.0'
|
testImplementation 'com.jayway.jsonpath:json-path:2.9.0'
|
||||||
|
@ -1780,6 +1780,7 @@ public class JSONObject {
|
|||||||
|
|
||||||
Method[] methods = includeSuperClass ? klass.getMethods() : klass.getDeclaredMethods();
|
Method[] methods = includeSuperClass ? klass.getMethods() : klass.getDeclaredMethods();
|
||||||
for (final Method method : methods) {
|
for (final Method method : methods) {
|
||||||
|
if (isValidMethod(method)) {
|
||||||
final String key = getKeyNameFromMethod(method);
|
final String key = getKeyNameFromMethod(method);
|
||||||
if (key != null && !key.isEmpty()) {
|
if (key != null && !key.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
@ -1808,16 +1809,13 @@ public class JSONObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean isValidMethodName(String name) {
|
private static boolean isValidMethodName(String name) {
|
||||||
return !"getClass".equals(name) && !"getDeclaringClass".equals(name);
|
return !"getClass".equals(name) && !"getDeclaringClass".equals(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getKeyNameFromMethod(Method method) {
|
private static String getKeyNameFromMethod(Method method) {
|
||||||
if (!isValidMethod(method)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int ignoreDepth = getAnnotationDepth(method, JSONPropertyIgnore.class);
|
final int ignoreDepth = getAnnotationDepth(method, JSONPropertyIgnore.class);
|
||||||
if (ignoreDepth > 0) {
|
if (ignoreDepth > 0) {
|
||||||
final int forcedNameDepth = getAnnotationDepth(method, JSONPropertyName.class);
|
final int forcedNameDepth = getAnnotationDepth(method, JSONPropertyName.class);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user