Package io.vertx.lang.groovy
Class VertxExtensionModule
- java.lang.Object
-
- io.vertx.lang.groovy.VertxExtensionModule
-
public class VertxExtensionModule extends Object
Extension module for integrating Vert.x common types with Groovy.
-
-
Constructor Summary
Constructors Constructor Description VertxExtensionModule()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
asBoolean(AsyncResult self)
Coerces anAsyncResult
as a boolean value according to Groovy-Truth.static Object
asType(Map map, Class clazz)
Convert a JSON like map data structure to a Vert.x data object or aJsonObject
.static Object
getAt(JsonArray json, int idx)
Subscript operator forJsonArray
, the read part.static Object
getAt(JsonObject json, String key)
Subscript operator forJsonObject
, the read part.static void
leftShift(JsonArray json, Object value)
<<
operator forJsonObject
.static Object
putAt(JsonObject json, String key, Object value)
Subscript operator forJsonObject
, the write part.
-
-
-
Method Detail
-
asType
public static Object asType(Map map, Class clazz) throws Throwable
Convert a JSON like map data structure to a Vert.x data object or aJsonObject
.The data object is a class annotated by
DataObject
that provides a public constructor with aJsonObject
argument.- Parameters:
map
- the JSON like map like data structureclazz
- the target type which can be a Java class annotated withDataObject
and provides aJsonObject
constructor, orJsonObject
- Returns:
- an instance of the specified
clazz
- Throws:
Throwable
-
getAt
public static Object getAt(JsonObject json, String key)
Subscript operator forJsonObject
, the read part.- Parameters:
json
- the json objectkey
- the key- Returns:
- the json value for
key
-
putAt
public static Object putAt(JsonObject json, String key, Object value)
Subscript operator forJsonObject
, the write part.- Parameters:
json
- the json objectkey
- the keyvalue
- the json value- Returns:
- the previous json value for
key
-
getAt
public static Object getAt(JsonArray json, int idx)
Subscript operator forJsonArray
, the read part.- Parameters:
json
- the json arrayidx
- the idx- Returns:
- the json value for
idx
-
leftShift
public static void leftShift(JsonArray json, Object value)
<<
operator forJsonObject
.- Parameters:
json
- the json objectvalue
- the json value
-
asBoolean
public static boolean asBoolean(AsyncResult self)
Coerces anAsyncResult
as a boolean value according to Groovy-Truth.- Parameters:
self
- theAsyncResult
instance- Returns:
- true if succeeded
-
-