public final class GerritJsonEventFactory extends Object
| Modifier and Type | Method and Description |
|---|---|
static GerritJsonEvent |
getEvent(net.sf.json.JSONObject jsonObject)
Creates a GerritJsonEvent DTO out of the provided JSONObject.
|
static GerritJsonEvent |
getEventIfInteresting(String jsonString)
Tries to parse the provided string into a GerritJsonEvent DTO if it is interesting and usable.
|
static net.sf.json.JSONObject |
getJsonObjectIfInterestingAndUsable(String jsonString)
Tries to parse the provided string into a JSONObject and returns it if it is interesting and usable.
|
static String |
getString(net.sf.json.JSONObject json,
String key)
Returns the value of a JSON property as a String if it exists otherwise returns null.
|
static String |
getString(net.sf.json.JSONObject json,
String key,
String defaultValue)
Returns the value of a JSON property as a String if it exists otherwise returns the defaultValue.
|
static boolean |
isInterestingAndUsable(String jsonString)
Tells if the provided string is a valid JSON string
and represents an interesting and usable
GerritJsonEvent
as defined by getJsonObjectIfInterestingAndUsable(java.lang.String). |
public static GerritJsonEvent getEvent(net.sf.json.JSONObject jsonObject)
getJsonObjectIfInterestingAndUsable(java.lang.String)jsonObject - the parsed JSON Objectpublic static boolean isInterestingAndUsable(String jsonString)
GerritJsonEvent
as defined by getJsonObjectIfInterestingAndUsable(java.lang.String).
This is the same as doing (getJsonObjectIfInterestingAndUsable(jsonString) != null)jsonString - the JSON formatted String.public static net.sf.json.JSONObject getJsonObjectIfInterestingAndUsable(String jsonString)
GerritEventType.findByTypeValue(java.lang.String)GerritEventType.isInteresting() == trueGerritEventType.getEventRepresentative() is not null.jsonString - the string to parse.public static GerritJsonEvent getEventIfInteresting(String jsonString)
jsonString - the JSON formatted string.getJsonObjectIfInterestingAndUsable(String)public static String getString(net.sf.json.JSONObject json, String key, String defaultValue)
json - the JSONObject to check.key - the keydefaultValue - the value to return if the key is missingpublic static String getString(net.sf.json.JSONObject json, String key)
getString(net.sf.json.JSONObject, java.lang.String, java.lang.String)
with null as defaultValue.json - the JSONObject to check.key - the keyCopyright © 2004-2015 Hudson. All Rights Reserved.