[Lada-commits] [PATCH 02 of 10] Added interfaces classes and annotations used for validation

Wald Commits scm-commit at wald.intevation.org
Tue Feb 24 14:57:44 CET 2015


# HG changeset patch
# User Raimund Renkert <raimund.renkert at intevation.de>
# Date 1424771534 -3600
# Node ID 23130e40e5b7d73942ef7b93f801882ca074ed36
# Parent  ce6964c274105fdc399e03c393e4330517ae8729
Added interfaces classes and annotations used for validation.

diff -r ce6964c27410 -r 23130e40e5b7 src/main/java/de/intevation/lada/validation/Validator.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/validation/Validator.java	Tue Feb 24 10:52:14 2015 +0100
@@ -0,0 +1,18 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+package de.intevation.lada.validation;
+
+
+/**
+ *
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+public interface Validator {
+
+    public Violation validate(Object object);
+}
diff -r ce6964c27410 -r 23130e40e5b7 src/main/java/de/intevation/lada/validation/Violation.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/validation/Violation.java	Tue Feb 24 10:52:14 2015 +0100
@@ -0,0 +1,59 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+package de.intevation.lada.validation;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ *
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+public class Violation {
+
+    private Map<String, Integer> warnings;
+
+    private Map<String, Integer> errors;
+
+    public Violation() {
+        this.warnings = new HashMap<String, Integer>();
+        this.errors = new HashMap<String, Integer>();
+    }
+
+    public Map<String, Integer> getWarnings() {
+        return this.warnings;
+    }
+
+    public Map<String, Integer> getErrors() {
+        return this.errors;
+    }
+
+    public void addWarning(String key, Integer value) {
+        this.warnings.put(key, value);
+    }
+
+    public void addError(String key, Integer value) {
+        this.errors.put(key, value);
+    }
+
+    public void addWarnings(Map<String, Integer> warnings) {
+        this.warnings.putAll(warnings);
+    }
+
+    public void addErrors(Map<String, Integer> errors) {
+        this.errors.putAll(errors);
+    }
+
+    public boolean hasWarnings() {
+        return this.warnings.size() > 0;
+    }
+
+    public boolean hasErrors() {
+        return this.errors.size() > 0;
+    }
+}
diff -r ce6964c27410 -r 23130e40e5b7 src/main/java/de/intevation/lada/validation/annotation/ValidationConfig.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/validation/annotation/ValidationConfig.java	Tue Feb 24 10:52:14 2015 +0100
@@ -0,0 +1,31 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+package de.intevation.lada.validation.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+
+/**
+ *
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+ at Qualifier
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({
+    ElementType.TYPE,
+    ElementType.FIELD,
+    ElementType.METHOD,
+    ElementType.PARAMETER})
+public @interface ValidationConfig {
+    String type() default "";
+}
diff -r ce6964c27410 -r 23130e40e5b7 src/main/java/de/intevation/lada/validation/annotation/ValidationRule.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/validation/annotation/ValidationRule.java	Tue Feb 24 10:52:14 2015 +0100
@@ -0,0 +1,31 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+package de.intevation.lada.validation.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+
+/**
+ *
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+ at Qualifier
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({
+    ElementType.TYPE,
+    ElementType.FIELD,
+    ElementType.METHOD,
+    ElementType.PARAMETER})
+public @interface ValidationRule {
+    String value() default "";
+}
diff -r ce6964c27410 -r 23130e40e5b7 src/main/java/de/intevation/lada/validation/rules/Rule.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/java/de/intevation/lada/validation/rules/Rule.java	Tue Feb 24 10:52:14 2015 +0100
@@ -0,0 +1,19 @@
+/* Copyright (C) 2013 by Bundesamt fuer Strahlenschutz
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU GPL (v>=3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out
+ * the documentation coming with IMIS-Labordaten-Application for details.
+ */
+package de.intevation.lada.validation.rules;
+
+import de.intevation.lada.validation.Violation;
+
+/**
+ *
+ * @author <a href="mailto:raimund.renkert at intevation.de">Raimund Renkert</a>
+ */
+public interface Rule {
+
+    public Violation execute(Object object);
+}


More information about the Lada-commits mailing list