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