/** * For those {@link Rel}s that also take a param */ public String andParam(String paramName, String paramValue) { return getName() + (relDef.canAddParams() ?";" + paramName + "=" + "\"" + paramValue + "\"" :""); }
/** * Will lazily create extensions map as required */ protected JsonRepresentation getExtensions() { JsonRepresentation extensions = representation.getMap("extensions"); if (extensions == null) { extensions = JsonRepresentation.newMap(); representation.mapPut("extensions", extensions); } return extensions; }
@Before public void setUp() throws Exception { link = new LinkRepresentation().withHref("http://foo/bar").withMethod(RestfulHttpMethod.GET); jsonRepresentation = new JsonRepresentation(readJson("map.json")); }
@Override public void appendValueAndFormat(ObjectAdapter objectAdapter, String format, JsonRepresentation repr) { final Object obj = unwrapAsObjectElseNullNode(objectAdapter); if(obj instanceof Byte) { final Byte b = (Byte) obj; repr.mapPut("value", b); } else { repr.mapPut("value", obj); } appendFormats(repr, this.format, xIsisFormat); } });
/** * Use {@link #isDouble()} to check first, if required. */ public Double asDouble() { return getDouble(null, asJsonNode()); }
/** * Use {@link #isInt()} to check first, if required. */ public Integer asInt() { return getInt(null, asJsonNode()); }
/** * Use {@link #isIntegralNumber()} to test if number (it is not possible to check if a byte, however). */ public Byte asByte() { return getByte(null, asJsonNode()); }
/** * Either returns a {@link JsonRepresentation} that indicates that the * wrapped node has <tt>null</tt> value (ie * {@link JsonRepresentation#isNull()}), or returns <tt>null</tt> if there * was no node with the provided path. * * <p> * Use {@link #isNull()} to check first, if required. */ public JsonRepresentation asNull() { return getNull(null, asJsonNode()); }
/** * Use {@link #isBigInteger(String)} to check first, if required. */ public BigInteger getBigInteger(final String path) { return getBigInteger(path, (String)null); }
public LinkRepresentation getLinkWithRel(final Rel rel) { for (final LinkRepresentation linkRepr : getLinks().arrayIterable(LinkRepresentation.class)) { if(rel.matches(linkRepr.getRel())) { return linkRepr; } } return null; }
/** * Is a long, an int or a {@link BigInteger}. */ public boolean isIntegralNumber(final String path) { return isIntegralNumber(getNode(path)); }
@Override public String asString(final RepresentationType t) { return t.getName(); } };
@Override public void appendValueAndFormat(ObjectAdapter objectAdapter, String format, JsonRepresentation repr) { final Object obj = unwrapAsObjectElseNullNode(objectAdapter); if(obj instanceof Double) { final Double d = (Double) obj; repr.mapPut("value", d); } else { repr.mapPut("value", obj); } appendFormats(repr, this.format, xIsisFormat); } });