001/* 002 * SPDX-FileCopyrightText: none 003 * SPDX-License-Identifier: CC0-1.0 004 */ 005 006package dev.metaschema.core.configuration; 007 008import org.eclipse.jdt.annotation.Owning; 009 010import edu.umd.cs.findbugs.annotations.NonNull; 011 012/** 013 * This interface provides methods for retrieving and updating the configuration 014 * of processors and parsers in this library. This provides a mutable view of 015 * the current configuration. 016 * 017 * @param <T> 018 * the type of the feature set 019 */ 020public interface IMutableConfiguration<T extends IConfigurationFeature<?>> 021 extends IConfiguration<T> { 022 /** 023 * Turn on the provided feature. 024 * 025 * @param feature 026 * the feature to turn on 027 * @return the updated configuration 028 * @throws UnsupportedOperationException 029 * if the feature is not a boolean valued feature 030 * @see IConfigurationFeature#getValueClass() 031 */ 032 @NonNull 033 @Owning 034 default IMutableConfiguration<T> enableFeature(@NonNull T feature) { 035 return set(feature, true); 036 } 037 038 /** 039 * Turn off the provided feature. 040 * 041 * @param feature 042 * the feature to turn off 043 * @return the updated configuration 044 * @throws UnsupportedOperationException 045 * if the feature is not a boolean valued feature 046 * @see IConfigurationFeature#getValueClass() 047 */ 048 @NonNull 049 @Owning 050 default IMutableConfiguration<T> disableFeature(@NonNull T feature) { 051 return set(feature, false); 052 } 053 054 /** 055 * Replace this configuration with the {@code other} configuration. 056 * 057 * @param other 058 * the new configuration 059 * @return the updated configuration 060 */ 061 @NonNull 062 @Owning 063 IMutableConfiguration<T> applyConfiguration(@NonNull IConfiguration<T> other); 064 065 /** 066 * Set the value of the provided {@code feature} to the provided value. 067 * 068 * @param feature 069 * the feature to set 070 * @param value 071 * the value to set 072 * @return the updated configuration 073 * @throws UnsupportedOperationException 074 * if the provided feature value is not assignment compatible with the 075 * features value type 076 * @see IConfigurationFeature#getValueClass() 077 */ 078 @NonNull 079 @Owning 080 IMutableConfiguration<T> set(@NonNull T feature, @NonNull Object value); 081}