MutableConfiguration.java
01 /*
02  * SPDX-License-Identifier: Apache-2.0
03  *
04  * Copyright 2008-2017 the original author or authors.
05  *
06  * Licensed under the Apache License, Version 2.0 (the "License");
07  * you may not use this file except in compliance with the License.
08  * You may obtain a copy of the License at
09  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 package griffon.core;
19 
20 import javax.annotation.Nonnull;
21 import javax.annotation.Nullable;
22 
23 /**
24  @author Andres Almiray
25  @since 2.2.0
26  */
27 public interface MutableConfiguration extends Configuration {
28     /**
29      * Sets a key/value pair on this configuration.
30      *
31      @param key   the key to be registered
32      @param value the value to save
33      */
34     void set(@Nonnull String key, @Nonnull Object value);
35 
36     /**
37      * Removes a key from this configuration.
38      *
39      @param key the key to be removed
40      @return the value associated with the key or <tt>null</tt> if there wasn't any value.
41      */
42     @Nullable
43     Object remove(@Nonnull String key);
44 
45     /**
46      * Removes a key from this configuration.
47      * Blindly casts the returned value.
48      *
49      @param key the key to be removed
50      @return the value associated with the key or <tt>null</tt> if there wasn't any value.
51      @since 2.5.0
52      */
53     @Nullable
54     <T> T removeAs(@Nonnull String key);
55 
56     /**
57      * Removes a key from this configuration. The value is
58      * converted to type <tt>T</tt> if found using a {@code PropertyEditor}.
59      *
60      @param key  the key to be removed
61      @param type the type to be returned
62      @return the value associated with the key or <tt>null</tt> if there wasn't any value.
63      @since 2.5.0
64      */
65     @Nullable
66     <T> T removeConverted(@Nonnull String key, @Nonnull Class<T> type);
67 }