aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/enumerations
diff options
context:
space:
mode:
authorbananeweizen <bananeweizen@gmx.de>2011-10-31 19:21:25 +0100
committerbananeweizen <bananeweizen@gmx.de>2011-10-31 19:21:25 +0100
commit5bf29d09cf3d19e863e7bdca3dbe3d108c137799 (patch)
treea84ab256f5fb5dd10f039a9dbc36ad9acb04a8da /main/src/cgeo/geocaching/enumerations
parent28f8b812092ebe6015a53f0f60bc838ffe24f270 (diff)
downloadcgeo-5bf29d09cf3d19e863e7bdca3dbe3d108c137799.zip
cgeo-5bf29d09cf3d19e863e7bdca3dbe3d108c137799.tar.gz
cgeo-5bf29d09cf3d19e863e7bdca3dbe3d108c137799.tar.bz2
avoid NPE when accessing cache type, #737
Diffstat (limited to 'main/src/cgeo/geocaching/enumerations')
-rw-r--r--main/src/cgeo/geocaching/enumerations/CacheType.java12
1 files changed, 10 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/enumerations/CacheType.java b/main/src/cgeo/geocaching/enumerations/CacheType.java
index 1e58b70..e8f19cc 100644
--- a/main/src/cgeo/geocaching/enumerations/CacheType.java
+++ b/main/src/cgeo/geocaching/enumerations/CacheType.java
@@ -55,11 +55,19 @@ public enum CacheType {
}
public final static CacheType getById(final String id) {
- return CacheType.FIND_BY_ID.get(id.toLowerCase().trim());
+ final CacheType result = CacheType.FIND_BY_ID.get(id.toLowerCase().trim());
+ if (result == null) {
+ return UNKNOWN;
+ }
+ return result;
}
public final static CacheType getByPattern(final String pattern) {
- return CacheType.FIND_BY_PATTERN.get(pattern.toLowerCase().trim());
+ final CacheType result = CacheType.FIND_BY_PATTERN.get(pattern.toLowerCase().trim());
+ if (result == null) {
+ return UNKNOWN;
+ }
+ return result;
}
}