aboutsummaryrefslogtreecommitdiffstats
path: root/utils/src/main/java/org/onap/policy/common/utils/properties/Property.java
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2019-03-04 16:03:26 -0500
committerJim Hahn <jrh3@att.com>2019-03-04 20:12:27 -0500
commitfabde091ed5589552885265f8ed91bc1d72a9a6e (patch)
tree0ac567b3b063e4be61599b3fdeca95a097bd7c80 /utils/src/main/java/org/onap/policy/common/utils/properties/Property.java
parente7ad7f65ed1c66b6ec2af6d415a386c931bfe20c (diff)
Add bean configurator
Refactored PropertyConfiguration, but left the original class alone until references to it have been removed from other policy repos. Split the Property annotation out into its own file. Cloned the remaining code into BeanConfigurator, modifying its behavior so that, instead of operating on its own subclass, it operates on a provided bean. Also added an ability to copy the bean's fields to a Properties object. Updated license dates. Removed unneeded argument from functional interface. Added comment about always checking default values. Updated a few comments. Change-Id: Iff36fd0524032d7630f9ee08f0eef7b05de100d1 Issue-ID: POLICY-1444 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'utils/src/main/java/org/onap/policy/common/utils/properties/Property.java')
-rw-r--r--utils/src/main/java/org/onap/policy/common/utils/properties/Property.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/utils/src/main/java/org/onap/policy/common/utils/properties/Property.java b/utils/src/main/java/org/onap/policy/common/utils/properties/Property.java
new file mode 100644
index 00000000..bacedef9
--- /dev/null
+++ b/utils/src/main/java/org/onap/policy/common/utils/properties/Property.java
@@ -0,0 +1,59 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP
+ * ================================================================================
+ * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.common.utils.properties;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.Properties;
+
+
+/**
+ * Annotation that declares a variable to be configured via {@link Properties}.
+ */
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface Property {
+
+ /**
+ * Name of the property.
+ *
+ * @return the property name
+ */
+ public String name();
+
+ /**
+ * Default value, used when the property does not exist.
+ *
+ * @return the default value
+ */
+ public String defaultValue() default "";
+
+ /**
+ * Comma-separated options identifying what's acceptable. The word, "empty",
+ * indicates that an empty string, "", is an acceptable value.
+ *
+ * @return options identifying what's acceptable
+ */
+ public String accept() default "";
+}