diff options
author | Eduardo Pedroni <e.pedroni91@gmail.com> | 2016-08-14 18:09:22 +0200 |
---|---|---|
committer | Eduardo Pedroni <e.pedroni91@gmail.com> | 2016-08-14 18:09:22 +0200 |
commit | 8cb35b358563e5a81ad9e4aceb123b85222cf4cc (patch) | |
tree | 0d73eebfe29e7d90d4e0d6c5d40a36db75de3fdc /src/eu/equalparts/cardbase/utils | |
parent | 78e369043f95e78b27c265f7eab4d766e54054f4 (diff) |
Implemented some more filtering tests, sorted out validation and exceptions
Diffstat (limited to 'src/eu/equalparts/cardbase/utils')
-rw-r--r-- | src/eu/equalparts/cardbase/utils/InputSanity.java | 27 | ||||
-rw-r--r-- | src/eu/equalparts/cardbase/utils/Utils.java | 15 |
2 files changed, 15 insertions, 27 deletions
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<? extends Annotation> annotation) { + for (Annotation a : fieldToAnalyse.getAnnotations()) { + if (a.annotationType().equals(annotation)) { + return true; + } + } + return false; + } +} |