ConfigurationDescriptor.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 org.codehaus.griffon.runtime.core.configuration;
19 
20 import javax.annotation.Nonnull;
21 import javax.annotation.Nullable;
22 import java.beans.PropertyEditor;
23 
24 import static griffon.util.GriffonNameUtils.requireNonBlank;
25 
26 /**
27  @author Andres Almiray
28  @since 2.11.0
29  */
30 public abstract class ConfigurationDescriptor {
31     private final String configuration;
32     private final String key;
33     private final String defaultValue;
34     private final String format;
35     private final Class<? extends PropertyEditor> editor;
36 
37     public ConfigurationDescriptor(@Nonnull String configuration, @Nonnull String key, @Nullable String defaultValue, @Nonnull String format, @Nonnull Class<? extends PropertyEditor> editor) {
38         this.configuration = configuration;
39         this.key = requireNonBlank(key, "Argument 'key' must not be blank");
40         this.defaultValue = defaultValue;
41         this.format = format;
42         this.editor = editor;
43     }
44 
45     @Nonnull
46     public String getConfiguration() {
47         return configuration;
48     }
49 
50     @Nonnull
51     public String getKey() {
52         return key;
53     }
54 
55     @Nullable
56     public String getDefaultValue() {
57         return defaultValue;
58     }
59 
60     @Nonnull
61     public String getFormat() {
62         return format;
63     }
64 
65     @Nonnull
66     public Class<? extends PropertyEditor> getEditor() {
67         return editor;
68     }
69 
70     @Nonnull
71     public abstract InjectionPoint asInjectionPoint();
72 }