1
2
3
4
5
6 package gov.nist.secauto.metaschema.databind.io;
7
8 import gov.nist.secauto.metaschema.core.model.IBoundObject;
9 import gov.nist.secauto.metaschema.databind.model.IBoundDefinitionModelComplex;
10 import gov.nist.secauto.metaschema.databind.model.IBoundProperty;
11
12 import java.io.IOException;
13 import java.util.Collection;
14
15 import edu.umd.cs.findbugs.annotations.NonNull;
16
17 public abstract class AbstractProblemHandler implements IProblemHandler {
18
19 @Override
20 public void handleMissingInstances(
21 IBoundDefinitionModelComplex parentDefinition,
22 IBoundObject targetObject,
23 Collection<? extends IBoundProperty<?>> unhandledInstances) throws IOException {
24 applyDefaults(targetObject, unhandledInstances);
25 }
26
27
28
29
30
31
32
33
34
35
36
37
38
39 protected static void applyDefaults(
40 @NonNull Object targetObject,
41 @NonNull Collection<? extends IBoundProperty<?>> unhandledInstances) throws IOException {
42 for (IBoundProperty<?> instance : unhandledInstances) {
43 Object value = instance.getResolvedDefaultValue();
44 if (value != null) {
45 instance.setValue(targetObject, value);
46 }
47 }
48 }
49 }