blob: 361c0e5f875604449505ce4940d7de0f412cdaf3 (
plain) (
tree)
|
|
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();
}
public static int parseInt(String str, int def)
{
try {
return Integer.parseInt( str );
} catch (Throwable t) {
return def;
}
}
}
|