1 /* 2 * SPDX-FileCopyrightText: none 3 * SPDX-License-Identifier: CC0-1.0 4 */ 5 6 package gov.nist.secauto.metaschema.core.model; 7 8 import edu.umd.cs.findbugs.annotations.Nullable; 9 10 /** 11 * A marker interface for Metaschema constructs that can have a default value. 12 */ 13 public interface IDefaultable { 14 15 /** 16 * Retrieves the default data value for this model construct. 17 * <p> 18 * Child implementations are expected to override this method to provide a more 19 * reasonable default value. 20 * 21 * @return the default value or {@code null} if there is no default 22 */ 23 // from: IModelElement 24 @Nullable 25 default Object getDefaultValue() { 26 // no value by default 27 return null; 28 } 29 30 /** 31 * Get the effective default value for the model construct. 32 * <p> 33 * This should consider default values in any related referenced definitions or 34 * child constructs as needed to determine the default to use. 35 * 36 * @return the effective default value or {@code null} if there is no effective 37 * default value 38 */ 39 // from IInstance 40 @Nullable 41 default Object getEffectiveDefaultValue() { 42 return getDefaultValue(); 43 } 44 45 /** 46 * Get the actual default value to use for the model construct. 47 * <p> 48 * This will consider the effective default value in the use context to 49 * determine the appropriate default to use. Factors such as the required 50 * instance cardinality may affect if the effective default or an empty 51 * collection is used. 52 * 53 * @return the actual default value or {@code null} if there is no actual 54 * default value 55 */ 56 @Nullable 57 default Object getResolvedDefaultValue() { 58 return getEffectiveDefaultValue(); 59 } 60 }