From efb5ad9f5fe48a77b6cd14e7bd2b25e3b13ecb1f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 3 Jun 2014 16:44:56 +0200 Subject: Initial commit --- .../java/org/openslx/taskmanager/util/Util.java | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 daemon/src/main/java/org/openslx/taskmanager/util/Util.java (limited to 'daemon/src/main/java/org/openslx/taskmanager/util/Util.java') diff --git a/daemon/src/main/java/org/openslx/taskmanager/util/Util.java b/daemon/src/main/java/org/openslx/taskmanager/util/Util.java new file mode 100644 index 0000000..bf52ecb --- /dev/null +++ b/daemon/src/main/java/org/openslx/taskmanager/util/Util.java @@ -0,0 +1,24 @@ +package org.openslx.taskmanager.util; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +public class Util +{ + + private static GsonBuilder gsonBuilder = new GsonBuilder(); + + /** + * Small helper to create a gson instance that will only handle class members with the + * "@Exposed" annotation. Decided against the default of explicitly excluding fields by + * making them transient, as you might easily forget to exclude an important field, which + * can in turn be a security issue. + * + * @return Gson instance + */ + public static Gson explicitGsonInstance() + { + return gsonBuilder.excludeFieldsWithoutExposeAnnotation().create(); + } + +} -- cgit v1.2.3-55-g7522