This is an automated email from the ASF dual-hosted git repository. cdutz pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/plc4x.git
commit f58ceb6caef52e61a2669c599904d458a144af66 Author: Christofer Dutz <[email protected]> AuthorDate: Thu Jul 9 16:33:06 2020 +0200 Added support for Float default values --- .../spi/configuration/ConfigurationFactory.java | 9 +++--- .../annotations/defaults/FloatDefaultValue.java | 33 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/ConfigurationFactory.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/ConfigurationFactory.java index 088cd1f..80165d5 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/ConfigurationFactory.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/ConfigurationFactory.java @@ -24,10 +24,7 @@ import org.apache.commons.lang3.ClassUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.reflect.FieldUtils; import org.apache.plc4x.java.spi.configuration.annotations.*; -import org.apache.plc4x.java.spi.configuration.annotations.defaults.BooleanDefaultValue; -import org.apache.plc4x.java.spi.configuration.annotations.defaults.DoubleDefaultValue; -import org.apache.plc4x.java.spi.configuration.annotations.defaults.IntDefaultValue; -import org.apache.plc4x.java.spi.configuration.annotations.defaults.StringDefaultValue; +import org.apache.plc4x.java.spi.configuration.annotations.defaults.*; import java.io.UnsupportedEncodingException; import java.lang.reflect.Field; @@ -224,6 +221,10 @@ public class ConfigurationFactory { if (booleanDefaultValue != null) { return booleanDefaultValue.value(); } + FloatDefaultValue floatDefaultValue = field.getAnnotation(FloatDefaultValue.class); + if (floatDefaultValue != null) { + return floatDefaultValue.value(); + } DoubleDefaultValue doubleDefaultValue = field.getAnnotation(DoubleDefaultValue.class); if (doubleDefaultValue != null) { return doubleDefaultValue.value(); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/annotations/defaults/FloatDefaultValue.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/annotations/defaults/FloatDefaultValue.java new file mode 100644 index 0000000..2b04520 --- /dev/null +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/annotations/defaults/FloatDefaultValue.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +package org.apache.plc4x.java.spi.configuration.annotations.defaults; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface FloatDefaultValue { + + float value(); + +}
