Java Code Examples for javax.ws.rs.core.Link#getType()

The following examples show how to use javax.ws.rs.core.Link#getType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceSupport.java    From container with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(final Link link, final JsonGenerator json,
                      final SerializerProvider provider) throws IOException {
    if (link.getUri() == null || link.getRel() == null || link.getRel().isEmpty()) {
        return;
    }
    json.writeObjectFieldStart(link.getRel());
    json.writeStringField("href", link.getUri().toString());
    if (link.getTitle() != null && !link.getTitle().isEmpty()) {
        json.writeStringField(Link.TITLE, link.getTitle());
    }
    if (link.getType() != null && !link.getType().isEmpty()) {
        json.writeStringField(Link.TYPE, link.getType());
    }
    json.writeEndObject();
}
 
Example 2
Source File: LinkHeaderProvider.java    From cxf with Apache License 2.0 5 votes vote down vote up
public String toString(Link link) {
    StringBuilder sb = new StringBuilder();

    sb.append('<');
    sb.append(link.getUri());
    sb.append('>');

    String rels = link.getRel();
    if (!rels.isEmpty()) {
        sb.append(';').append(REL).append('=');
        writeListParamValues(sb, rels);
    }
    if (link.getTitle() != null) {
        sb.append(';').append(TITLE).append("=\"").append(link.getTitle()).append('"');
    }
    if (link.getType() != null) {
        sb.append(';').append(TYPE).append('=').append(link.getType());
    }
    for (Map.Entry<String, String> entry : link.getParams().entrySet()) {
        if (KNOWN_PARAMETERS.contains(entry.getKey())) {
            continue;
        }
        sb.append(';').append(entry.getKey()).append('=');
        writeListParamValues(sb, entry.getValue());
    }

    return sb.toString();

}
 
Example 3
Source File: ClientImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Override
public Builder invocation(Link link) {
    checkNull(link);
    checkClosed();
    Builder builder = target(link.getUriBuilder()).request();
    String type = link.getType();
    if (type != null) {
        builder.accept(type);
    }
    return builder;
}
 
Example 4
Source File: TenacityJerseyClient.java    From tenacity with Apache License 2.0 5 votes vote down vote up
@Override
public Invocation.Builder invocation(Link link) {
    WebTarget t = new TenacityWebTarget(
            delegate.target(link),
            tenacityPropertyKey,
            timeoutPadding
    );
    final String acceptType = link.getType();
    return (acceptType != null) ? t.request(acceptType) : t.request();
}