JsonRepresentation.getLink
Code IndexAdd Codota to your IDE (free)

Best Java code snippets using org.apache.isis.viewer.restfulobjects.applib.JsonRepresentation.getLink (Showing top 20 results out of 315)

  • Common ways to obtain JsonRepresentation
private void myMethod () {
JsonRepresentation j =
  • JsonRepresentation.newMap()
  • JsonRepresentation.newArray()
  • JsonRepresentation.newMap("<changeme>", "<changeme>")
  • Smart code suggestions by Codota
}
origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

/**
 * Use {@link #isLink()} to check first, if required.
 */
public LinkRepresentation asLink() {
  return getLink(null, asJsonNode());
}
origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

/**
 * Use {@link #isLink(String)} to check first, if required.
 */
public LinkRepresentation getLink(final String path) {
  return getLink(path, getNode(path));
}
origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

/**
 * Convert a representation that contains a single node representing a link
 * into a {@link LinkRepresentation}.
 */
public LinkRepresentation mapValueAsLink() {
  if (asJsonNode().size() != 1) {
    throw new IllegalStateException("does not represent link");
  }
  final String linkPropertyName = asJsonNode().getFieldNames().next();
  return getLink(linkPropertyName);
}
origin: org.apache.isis.viewer/isis-viewer-restfulobjects-server

private static String linkFromFormalArgs(final String argumentsQueryString, final String paramName) {
  final JsonRepresentation arguments = DomainResourceHelper.readQueryStringAsMap(argumentsQueryString);
  if (!arguments.isLink(paramName)) {
    throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.BAD_REQUEST, "Args should contain a link '%s'", paramName);
  }
  return arguments.getLink(paramName).getHref();
}
origin: org.apache.isis.viewer/isis-viewer-restfulobjects-impl

private static String linkFromFormalArgs(final String argumentsQueryString, final String paramName) {
  final JsonRepresentation arguments = DomainResourceHelper.readQueryStringAsMap(argumentsQueryString);
  if (!arguments.isLink(paramName)) {
    throw RestfulObjectsApplicationException.create(HttpStatusCode.BAD_REQUEST, "Args should contain a link '%s'", paramName);
  }
  return arguments.getLink(paramName).getHref();
}
origin: org.apache.isis.core/isis-core-viewer-restfulobjects-server

private static String linkFromFormalArgs(final String argumentsAsQueryString, final String paramName) {
  final JsonRepresentation arguments = Util.readQueryStringAsMap(argumentsAsQueryString);
  if (!arguments.isLink(paramName)) {
    throw RestfulObjectsApplicationException.createWithMessage(HttpStatusCode.BAD_REQUEST, "Args should contain a link '%s'", paramName);
  }
  return arguments.getLink(paramName).getHref();
}
origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

@Test
public void forNonExistent() throws JsonParseException, JsonMappingException, IOException {
  assertThat(jsonRepresentation.isLink("doesNotExist"), is(false));
  assertThat(jsonRepresentation.getLink("doesNotExist"), is(nullValue()));
}
origin: org.apache.isis.core/isis-core-viewer-restfulobjects-applib

@Test
public void forNonExistent() throws IOException {
  assertThat(jsonRepresentation.isLink("doesNotExist"), is(false));
  assertThat(jsonRepresentation.getLink("doesNotExist"), is(nullValue()));
}
origin: org.apache.isis.core/isis-core-viewer-restfulobjects-applib

@Test
public void forList() throws IOException {
  assertThat(jsonRepresentation.isLink("aSubList"), is(false));
  try {
    jsonRepresentation.getLink("aSubList");
    fail();
  } catch (final IllegalArgumentException e) {
    assertThat(e.getMessage(), is("'aSubList' is an array that does not represent a link"));
  }
}
origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

@Test
public void forValue() throws JsonParseException, JsonMappingException, IOException {
  assertThat(jsonRepresentation.isLink("anInt"), is(false));
  try {
    jsonRepresentation.getLink("anInt");
    fail();
  } catch (final IllegalArgumentException e) {
    assertThat(e.getMessage(), is("'anInt' is a value that does not represent a link"));
  }
}
origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

@Test
public void forMap() throws JsonParseException, JsonMappingException, IOException {
  assertThat(jsonRepresentation.isLink("aSubMap"), is(false));
  try {
    jsonRepresentation.getLink("aSubMap");
    fail();
  } catch (final IllegalArgumentException e) {
    assertThat(e.getMessage(), is("'aSubMap' is a map that does not fully represent a link"));
  }
}
origin: org.apache.isis.core/isis-core-viewer-restfulobjects-applib

@Test
public void forMap() throws IOException {
  assertThat(jsonRepresentation.isLink("aSubMap"), is(false));
  try {
    jsonRepresentation.getLink("aSubMap");
    fail();
  } catch (final IllegalArgumentException e) {
    assertThat(e.getMessage(), is("'aSubMap' is a map that does not fully represent a link"));
  }
}
origin: org.apache.isis.core/isis-core-viewer-restfulobjects-applib

@Test
public void forValue() throws IOException {
  assertThat(jsonRepresentation.isLink("anInt"), is(false));
  try {
    jsonRepresentation.getLink("anInt");
    fail();
  } catch (final IllegalArgumentException e) {
    assertThat(e.getMessage(), is("'anInt' is a value that does not represent a link"));
  }
}
origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

@Test
public void forList() throws JsonParseException, JsonMappingException, IOException {
  assertThat(jsonRepresentation.isLink("aSubList"), is(false));
  try {
    jsonRepresentation.getLink("aSubList");
    fail();
  } catch (final IllegalArgumentException e) {
    assertThat(e.getMessage(), is("'aSubList' is an array that does not represent a link"));
  }
}
origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

@Test
public void forLink_whenMultipartKey() throws JsonParseException, JsonMappingException, IOException {
  link.withRel("someSubRel");
  assertThat(jsonRepresentation.isLink("aSubMap.aLink"), is(true));
  assertThat(jsonRepresentation.getLink("aSubMap.aLink"), is(link));
}
origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

@Test
public void forLink_whenSimpleKey() throws JsonParseException, JsonMappingException, IOException {
  link.withRel("someRel");
  assertThat(jsonRepresentation.isLink("aLink"), is(true));
  assertThat(jsonRepresentation.getLink("aLink"), is(link));
}
origin: org.apache.isis.core/isis-core-viewer-restfulobjects-applib

@Test
public void forLink_whenSimpleKey() throws IOException {
  link.withRel("someRel");
  assertThat(jsonRepresentation.isLink("aLink"), is(true));
  assertThat(jsonRepresentation.getLink("aLink"), is(link));
}
origin: org.apache.isis.core/isis-core-viewer-restfulobjects-applib

@Test
public void forLink_whenMultipartKey() throws IOException {
  link.withRel("someSubRel");
  assertThat(jsonRepresentation.isLink("aSubMap.aLink"), is(true));
  assertThat(jsonRepresentation.getLink("aSubMap.aLink"), is(link));
}
origin: org.apache.isis.core/isis-core-viewer-restfulobjects-applib

@Test
public void withPredicate() throws IOException {
  // given
  link = new LinkRepresentation().withRel(Rel.SELF).withHref("http://foo/bar").withMethod(RestfulHttpMethod.GET);
  JsonRepresentation linkListRepr = JsonRepresentation.newArray();
  linkListRepr.arrayAdd(link);
  jsonRepresentation = JsonRepresentation.newMap();
  jsonRepresentation.mapPut("links", linkListRepr);
  
  // when, then
  assertThat(jsonRepresentation.isLink("links[rel=self]"), is(true));
  assertThat(jsonRepresentation.getLink("links[rel=self]"), is(not(nullValue())));
  assertThat(jsonRepresentation.isLink("links[rel=other]"), is(false));
  assertThat(jsonRepresentation.getLink("links[rel=other]"), is(nullValue()));
}
origin: org.apache.isis.viewer/isis-viewer-restfulobjects-applib

@Test
public void withPredicate() throws JsonParseException, JsonMappingException, IOException {
  // given
  link = new LinkRepresentation().withRel(Rel.SELF).withHref("http://foo/bar").withMethod(RestfulHttpMethod.GET);
  JsonRepresentation linkListRepr = JsonRepresentation.newArray();
  linkListRepr.arrayAdd(link);
  jsonRepresentation = JsonRepresentation.newMap();
  jsonRepresentation.mapPut("links", linkListRepr);
  
  // when, then
  assertThat(jsonRepresentation.isLink("links[rel=self]"), is(true));
  assertThat(jsonRepresentation.getLink("links[rel=self]"), is(not(nullValue())));
  assertThat(jsonRepresentation.isLink("links[rel=other]"), is(false));
  assertThat(jsonRepresentation.getLink("links[rel=other]"), is(nullValue()));
}
org.apache.isis.viewer.restfulobjects.applibJsonRepresentationgetLink

Javadoc

Use #isLink(String) to check first, if required.

Popular methods of JsonRepresentation

  • getString
  • newMap
  • newArray
  • isMap
  • mapPut
  • getRepresentation
  • arrayAdd
  • isString
  • size
  • <init>
  • getArray
  • isBigDecimal
  • getArray,
  • isBigDecimal,
  • isBigInteger,
  • isBoolean,
  • isLink,
  • isLong,
  • isValue,
  • mapIterable,
  • asJsonNode

Popular in Java

  • Parsing JSON documents to java classes using gson
  • setRequestProperty (URLConnection)
  • requestLocationUpdates (LocationManager)
  • getApplicationContext (Context)
  • BufferedInputStream (java.io)
    A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
  • String (java.lang)
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • ImageIO (javax.imageio)
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t

For IntelliJ IDEA,
Android Studio or Eclipse

  • Search for JavaScript code betaCodota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutBlogContact Us
  • Plugin user guideTerms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)