001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package dev.metaschema.core.model; 007 008import edu.umd.cs.findbugs.annotations.Nullable; 009 010/** 011 * A marker interface for Metaschema constructs that can have a default value. 012 */ 013public interface IDefaultable { 014 015 /** 016 * Retrieves the default data value for this model construct. 017 * <p> 018 * Child implementations are expected to override this method to provide a more 019 * reasonable default value. 020 * 021 * @return the default value or {@code null} if there is no default 022 */ 023 // from: IModelElement 024 @Nullable 025 default Object getDefaultValue() { 026 // no value by default 027 return null; 028 } 029 030 /** 031 * Get the effective default value for the model construct. 032 * <p> 033 * This should consider default values in any related referenced definitions or 034 * child constructs as needed to determine the default to use. 035 * 036 * @return the effective default value or {@code null} if there is no effective 037 * default value 038 */ 039 // from IInstance 040 @Nullable 041 default Object getEffectiveDefaultValue() { 042 return getDefaultValue(); 043 } 044 045 /** 046 * Get the actual default value to use for the model construct. 047 * <p> 048 * This will consider the effective default value in the use context to 049 * determine the appropriate default to use. Factors such as the required 050 * instance cardinality may affect if the effective default or an empty 051 * collection is used. 052 * 053 * @return the actual default value or {@code null} if there is no actual 054 * default value 055 */ 056 @Nullable 057 default Object getResolvedDefaultValue() { 058 return getEffectiveDefaultValue(); 059 } 060}