This is an automated email from the ASF dual-hosted git repository.

sruehl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x-build-tools.git


The following commit(s) were added to refs/heads/develop by this push:
     new efbcecb  feat: add validation field
efbcecb is described below

commit efbcecbd9465dd88a324734ab6a52afed71a0abe
Author: Sebastian Rühl <[email protected]>
AuthorDate: Thu Jan 6 13:11:23 2022 +0100

    feat: add validation field
---
 .../types/fields/FieldConversions.java             | 15 ++++++++++-
 .../types/fields/ValidationField.java              | 30 ++++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git 
a/code-generation/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/FieldConversions.java
 
b/code-generation/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/FieldConversions.java
index d348fa8..3f63f70 100644
--- 
a/code-generation/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/FieldConversions.java
+++ 
b/code-generation/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/FieldConversions.java
@@ -290,7 +290,6 @@ public interface FieldConversions {
         return 
Optional.of(this).filter(UnknownField.class::isInstance).map(UnknownField.class::cast);
     }
 
-
     /**
      * @return true if {@code this} is instance of {@link VirtualField}
      */
@@ -304,6 +303,20 @@ public interface FieldConversions {
     default Optional<VirtualField> asVirtualField() {
         return 
Optional.of(this).filter(VirtualField.class::isInstance).map(VirtualField.class::cast);
     }
+    
+    /**
+     * @return true if {@code this} is instance of {@link ValidationField}
+     */
+    default boolean isValidationField() {
+        return this instanceof ValidationField;
+    }
+
+    /**
+     * @return a {@link ValidationField} if castable.
+     */
+    default Optional<ValidationField> asValidationField() {
+        return 
Optional.of(this).filter(ValidationField.class::isInstance).map(ValidationField.class::cast);
+    }
 
     /**
      * @return true if {@code this} is instance of {@link ArrayField} with 
{@link ArrayField.LoopType}{@code .COUNT} or
diff --git 
a/code-generation/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ValidationField.java
 
b/code-generation/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ValidationField.java
new file mode 100644
index 0000000..5062ff4
--- /dev/null
+++ 
b/code-generation/types-base/src/main/java/org/apache/plc4x/plugins/codegenerator/types/fields/ValidationField.java
@@ -0,0 +1,30 @@
+/*
+ * 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.plugins.codegenerator.types.fields;
+
+import org.apache.plc4x.plugins.codegenerator.types.terms.Term;
+
+import java.util.Optional;
+
+public interface ValidationField extends FieldConversions {
+
+    Term getValidationExpression();
+
+    Optional<String> getDescription();
+}

Reply via email to