001/*
002 * Copyright 2012-2017 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.configurationmetadata;
018
019import java.io.Serializable;
020
021/**
022 * Define a configuration property. Each property is fully identified by its
023 * {@link #getId() id} which is composed of a namespace prefix (the
024 * {@link ConfigurationMetadataGroup#getId() group id}), if any and the {@link #getName()
025 * name} of the property.
026 *
027 * @author Stephane Nicoll
028 * @since 1.3.0
029 */
030@SuppressWarnings("serial")
031public class ConfigurationMetadataProperty implements Serializable {
032
033        private String id;
034
035        private String name;
036
037        private String type;
038
039        private String description;
040
041        private String shortDescription;
042
043        private Object defaultValue;
044
045        private final Hints hints = new Hints();
046
047        private Deprecation deprecation;
048
049        /**
050         * The full identifier of the property, in lowercase dashed form (e.g.
051         * my.group.simple-property)
052         * @return the property id
053         */
054        public String getId() {
055                return this.id;
056        }
057
058        public void setId(String id) {
059                this.id = id;
060        }
061
062        /**
063         * The name of the property, in lowercase dashed form (e.g. simple-property). If this
064         * item does not belong to any group, the id is returned.
065         * @return the property name
066         */
067        public String getName() {
068                return this.name;
069        }
070
071        public void setName(String name) {
072                this.name = name;
073        }
074
075        /**
076         * The class name of the data type of the property. For example,
077         * {@code java.lang.String}.
078         * <p>
079         * For consistency, the type of a primitive is specified using its wrapper
080         * counterpart, i.e. {@code boolean} becomes {@code java.lang.Boolean}. If the type
081         * holds generic information, these are provided as well, i.e. a {@code HashMap} of
082         * String to Integer would be defined as {@code java.util.HashMap
083         * <java.lang.String,java.lang.Integer>}.
084         * <p>
085         * Note that this class may be a complex type that gets converted from a String as
086         * values are bound.
087         * @return the property type
088         */
089        public String getType() {
090                return this.type;
091        }
092
093        public void setType(String type) {
094                this.type = type;
095        }
096
097        /**
098         * A description of the property, if any. Can be multi-lines.
099         * @return the property description
100         * @see #getShortDescription()
101         */
102        public String getDescription() {
103                return this.description;
104        }
105
106        public void setDescription(String description) {
107                this.description = description;
108        }
109
110        /**
111         * A single-line, single-sentence description of this property, if any.
112         * @return the property short description
113         * @see #getDescription()
114         */
115        public String getShortDescription() {
116                return this.shortDescription;
117        }
118
119        public void setShortDescription(String shortDescription) {
120                this.shortDescription = shortDescription;
121        }
122
123        /**
124         * The default value, if any.
125         * @return the default value
126         */
127        public Object getDefaultValue() {
128                return this.defaultValue;
129        }
130
131        public void setDefaultValue(Object defaultValue) {
132                this.defaultValue = defaultValue;
133        }
134
135        /**
136         * Return the hints of this item.
137         * @return the hints
138         */
139        public Hints getHints() {
140                return this.hints;
141        }
142
143        /**
144         * The {@link Deprecation} for this property, if any.
145         * @return the deprecation
146         * @see #isDeprecated()
147         */
148        public Deprecation getDeprecation() {
149                return this.deprecation;
150        }
151
152        public void setDeprecation(Deprecation deprecation) {
153                this.deprecation = deprecation;
154        }
155
156        /**
157         * Specify if the property is deprecated.
158         * @return if the property is deprecated
159         * @see #getDeprecation()
160         */
161        public boolean isDeprecated() {
162                return this.deprecation != null;
163        }
164
165}