From 8cb35b358563e5a81ad9e4aceb123b85222cf4cc Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sun, 14 Aug 2016 18:09:22 +0200 Subject: Implemented some more filtering tests, sorted out validation and exceptions --- src/eu/equalparts/cardbase/utils/InputSanity.java | 27 ----------------------- src/eu/equalparts/cardbase/utils/Utils.java | 15 +++++++++++++ 2 files changed, 15 insertions(+), 27 deletions(-) delete mode 100644 src/eu/equalparts/cardbase/utils/InputSanity.java create mode 100644 src/eu/equalparts/cardbase/utils/Utils.java (limited to 'src/eu/equalparts/cardbase/utils') diff --git a/src/eu/equalparts/cardbase/utils/InputSanity.java b/src/eu/equalparts/cardbase/utils/InputSanity.java deleted file mode 100644 index 0571c73..0000000 --- a/src/eu/equalparts/cardbase/utils/InputSanity.java +++ /dev/null @@ -1,27 +0,0 @@ -package eu.equalparts.cardbase.utils; - -public class InputSanity { - public static boolean isInteger(String str) { - if (str == null) { - return false; - } - int length = str.length(); - if (length == 0) { - return false; - } - int i = 0; - if (str.charAt(0) == '-') { - if (length == 1) { - return false; - } - i = 1; - } - for (; i < length; i++) { - char c = str.charAt(i); - if (c < '0' || c > '9') { - return false; - } - } - return true; - } -} diff --git a/src/eu/equalparts/cardbase/utils/Utils.java b/src/eu/equalparts/cardbase/utils/Utils.java new file mode 100644 index 0000000..bb88397 --- /dev/null +++ b/src/eu/equalparts/cardbase/utils/Utils.java @@ -0,0 +1,15 @@ +package eu.equalparts.cardbase.utils; + +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; + +public class Utils { + public static boolean hasAnnotation(Field fieldToAnalyse, Class annotation) { + for (Annotation a : fieldToAnalyse.getAnnotations()) { + if (a.annotationType().equals(annotation)) { + return true; + } + } + return false; + } +} -- cgit v1.2.3