Package com.networknt.schema
Class ApplyDefaultsStrategy
- java.lang.Object
-
- com.networknt.schema.ApplyDefaultsStrategy
-
public class ApplyDefaultsStrategy extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
applyArrayDefaults
private boolean
applyPropertyDefaults
private boolean
applyPropertyDefaultsIfNull
(package private) static ApplyDefaultsStrategy
EMPTY_APPLY_DEFAULTS_STRATEGY
-
Constructor Summary
Constructors Constructor Description ApplyDefaultsStrategy(boolean applyPropertyDefaults, boolean applyPropertyDefaultsIfNull, boolean applyArrayDefaults)
Specify which default values to apply.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
shouldApplyArrayDefaults()
boolean
shouldApplyPropertyDefaults()
boolean
shouldApplyPropertyDefaultsIfNull()
-
-
-
Field Detail
-
EMPTY_APPLY_DEFAULTS_STRATEGY
static final ApplyDefaultsStrategy EMPTY_APPLY_DEFAULTS_STRATEGY
-
applyPropertyDefaults
private final boolean applyPropertyDefaults
-
applyPropertyDefaultsIfNull
private final boolean applyPropertyDefaultsIfNull
-
applyArrayDefaults
private final boolean applyArrayDefaults
-
-
Constructor Detail
-
ApplyDefaultsStrategy
public ApplyDefaultsStrategy(boolean applyPropertyDefaults, boolean applyPropertyDefaultsIfNull, boolean applyArrayDefaults)
Specify which default values to apply. We can apply property defaults only if they are missing or if they are declared to be null in the input json, and we can apply array defaults if they are declared to be null in the input json.Note that the walker changes the input object in place. If validation fails, the input object will be changed.
- Parameters:
applyPropertyDefaults
- if true then apply defaults inside json objects if the attribute is missingapplyPropertyDefaultsIfNull
- if true then apply defaults inside json objects if the attribute is explicitly nullapplyArrayDefaults
- if true then apply defaults inside json arrays if the attribute is explicitly null- Throws:
java.lang.IllegalArgumentException
- if applyPropertyDefaults is false and applyPropertyDefaultsIfNull is true
-
-