/** * Returns true if the raw value is an json array. * * <p/> * Same as {@link #isArray()}. */ default boolean isList() { return raw() instanceof List; }
/** * Returns the raw value as {@link Long}. */ default Long asLong() { return (Long)raw(); }
/** * Returns the raw value as {@link Integer}. */ default Integer asInteger() { return (Integer)raw(); }
/** * Returns true if the raw value is an json object. * * <p/> * Same as {@link #isMap()} */ default boolean isObject() { return raw() instanceof Map; }
/** * Returns true if the raw value is an json object. */ default boolean isMap() { return raw() instanceof Map; }
/** * Returns the raw value as {@link Double}. */ default Double asDouble() { return (Double) raw(); }
/** * Returns true if the raw value is an json array. */ default boolean isArray() { return raw() instanceof List; }
/** * Returns the raw value as {@link String}. */ default String asString() { return (String)raw(); }
/** * Returns <code>true</code> if the raw value is <code>null</code> */ default boolean isNull() { return null == raw(); }
/** * Returns the raw value as {@link Float}. */ default Float asFloat() { return (Float) raw(); }
/** * Converts the raw value to the given type. */ default <T> T convertTo(Class<T> type) { return Converts.convert(raw(), type); } }
@Override public void parseJson(JsonValue json) { if(json.isObject()) { JsonObject o = json.asJsonObject(); this.user = toRule(o.get("user")); this.client = toRule(o.get("client")); return; } Object v = json.raw(); if(v instanceof String) { this.parseString((String)v); return; } throw new IllegalStateException("Can't parse json value '" + v + "'"); }
public void read(MetaApi api, Resource resource, boolean global) { JsonValue v = JsonValue.of(JSON.decode(resource.getContent())); String path = !global ? PathDefParser.path("/app/operations/", resource) : null; if(v.isObject()) { read(api, global, path,(Map)v.raw()); }else if(v.isArray()) { for(Object map : v.asArray()) { read(api, global, path,(Map)map); } }else { throw new IllegalStateException("Invalid json format of tags, must be an array or an object"); } }