/** * Convenience method for returning the {@code next} link. * * @return the link, or {@code null} if the named link does not exist */ @JsonIgnore public Link getNext() { return getLink(JSONAPISpecConstants.NEXT); }
Field linkField = configuration.getLinksField(type); if (linkField != null) { linkField.set(result, new Links(mapLinks(source.get(LINKS))));
private void serializeLinks(JSONAPIDocument<?> document, ObjectNode resultNode, SerializationSettings settings) { if (document.getLinks() != null && !document.getLinks().getLinks().isEmpty() && shouldSerializeLinks(settings)) { resultNode.set(LINKS, objectMapper.valueToTree(document.getLinks()).get(LINKS)); } }
public String getNextCursorFromDocument(JSONAPIDocument document) { Links links = document.getLinks(); if (links == null) { return null; } Link nextLink = links.getNext(); if (nextLink == null) { return null; } String nextLinkString = nextLink.toString(); try { List<NameValuePair> queryParameters = URLEncodedUtils.parse(new URI(nextLinkString), "utf8"); for (NameValuePair pair : queryParameters) { String name = pair.getName(); if (name.equals("page[cursor]")) { return pair.getValue(); } } } catch (URISyntaxException e) { LOG.error(e.getMessage()); } return null; }
Field linkField = configuration.getLinksField(type); if (linkField != null) { linkField.set(result, new Links(mapLinks(source.get(LINKS))));
private void serializeLinks(JSONAPIDocument<?> document, ObjectNode resultNode, SerializationSettings settings) { if (document.getLinks() != null && !document.getLinks().getLinks().isEmpty() && shouldSerializeLinks(settings)) { resultNode.set(LINKS, objectMapper.valueToTree(document.getLinks()).get(LINKS)); } }
private JsonNode getRelationshipLinks(Object source, Relationship relationship, String ownerLink, SerializationSettings settings) throws IllegalAccessException { if (shouldSerializeLinks(settings)) { Links links = null; Field relationshipLinksField = configuration .getRelationshipLinksField(source.getClass(), relationship.value()); if (relationshipLinksField != null) { links = (Links) relationshipLinksField.get(source); } Map<String, Link> linkMap = new HashMap<>(); if (links != null) { linkMap.putAll(links.getLinks()); } if (!relationship.path().trim().isEmpty() && !linkMap.containsKey(SELF)) { linkMap.put(SELF, new Link(createURL(ownerLink, relationship.path()))); } if (!relationship.relatedPath().trim().isEmpty() && !linkMap.containsKey(RELATED)) { linkMap.put(RELATED, new Link(createURL(ownerLink, relationship.relatedPath()))); } if (!linkMap.isEmpty()) { return objectMapper.valueToTree(new Links(linkMap)).get(LINKS); } } return null; }
/** * Convenience method for returning the {@code self} link. * * @return the link, or {@code null} if the named link does not exist */ @JsonIgnore public Link getSelf() { return getLink(JSONAPISpecConstants.SELF); }
Field relationshipLinksField = configuration.getRelationshipLinksField(object.getClass(), field); if (relationshipLinksField != null) { Links links = new Links(mapLinks(relationship.get(LINKS))); relationshipLinksField.set(object, links);
private JsonNode getRelationshipLinks(Object source, Relationship relationship, String ownerLink, SerializationSettings settings) throws IllegalAccessException { if (shouldSerializeLinks(settings)) { Links links = null; Field relationshipLinksField = configuration .getRelationshipLinksField(source.getClass(), relationship.value()); if (relationshipLinksField != null) { links = (Links) relationshipLinksField.get(source); } Map<String, Link> linkMap = new HashMap<>(); if (links != null) { linkMap.putAll(links.getLinks()); } if (!relationship.path().trim().isEmpty() && !linkMap.containsKey(SELF)) { linkMap.put(SELF, new Link(createURL(ownerLink, relationship.path()))); } if (!relationship.relatedPath().trim().isEmpty() && !linkMap.containsKey(RELATED)) { linkMap.put(RELATED, new Link(createURL(ownerLink, relationship.relatedPath()))); } if (!linkMap.isEmpty()) { return objectMapper.valueToTree(new Links(linkMap)).get(LINKS); } } return null; }
/** * Convenience method for returning the {@code next} link. * * @return the link, or {@code null} if the named link does not exist */ @JsonIgnore public Link getNext() { return getLink(JSONAPISpecConstants.NEXT); }
result.setLinks(new Links(mapLinks(rootNode.get(LINKS))));
/** * Convenience method for returning the {@code last} link. * * @return the link, or {@code null} if the named link does not exist */ @JsonIgnore public Link getLast() { return getLink(JSONAPISpecConstants.LAST); }
result.setLinks(new Links(mapLinks(rootNode.get(LINKS))));
/** * Convenience method for returning the {@code self} link. * * @return the link, or {@code null} if the named link does not exist */ @JsonIgnore public Link getSelf() { return getLink(JSONAPISpecConstants.SELF); }
Field relationshipLinksField = configuration.getRelationshipLinksField(object.getClass(), field); if (relationshipLinksField != null) { Links links = new Links(mapLinks(relationship.get(LINKS))); relationshipLinksField.set(object, links);