Browse Source

Merge pull request #128 from trajano/getEffectiveDefaults-when-necessary

Only call getEffectiveDefaults when needed
pull/93/merge
kallestenflo 9 years ago
parent
commit
1cfe33998c
  1. 9
      json-path/src/main/java/com/jayway/jsonpath/Configuration.java

9
json-path/src/main/java/com/jayway/jsonpath/Configuration.java

@ -18,9 +18,6 @@ import com.jayway.jsonpath.internal.DefaultsImpl;
import com.jayway.jsonpath.spi.json.JsonProvider; import com.jayway.jsonpath.spi.json.JsonProvider;
import com.jayway.jsonpath.spi.mapper.MappingProvider; import com.jayway.jsonpath.spi.mapper.MappingProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
@ -36,8 +33,6 @@ import static java.util.Arrays.asList;
*/ */
public class Configuration { public class Configuration {
private static final Logger logger = LoggerFactory.getLogger(Configuration.class);
private static Defaults DEFAULTS = null; private static Defaults DEFAULTS = null;
/** /**
@ -230,13 +225,15 @@ public class Configuration {
} }
public Configuration build() { public Configuration build() {
Defaults defaults = getEffectiveDefaults(); if (jsonProvider == null || mappingProvider == null) {
final Defaults defaults = getEffectiveDefaults();
if (jsonProvider == null) { if (jsonProvider == null) {
jsonProvider = defaults.jsonProvider(); jsonProvider = defaults.jsonProvider();
} }
if (mappingProvider == null){ if (mappingProvider == null){
mappingProvider = defaults.mappingProvider(); mappingProvider = defaults.mappingProvider();
} }
}
return new Configuration(jsonProvider, mappingProvider, options, evaluationListener); return new Configuration(jsonProvider, mappingProvider, options, evaluationListener);
} }
} }

Loading…
Cancel
Save