Java 类javax.ws.rs.core.Link.Builder 实例源码
项目:sam
文件:LinkDeserializer.java
@Override
public Link deserialize(JsonParser jsonParser, DeserializationContext ctx) throws IOException, JsonProcessingException {
final ObjectCodec oc = jsonParser.getCodec();
final JsonNode node = oc.readTree(jsonParser);
final JsonNode href = node.get("href");
if (href == null) {
return null;
}
final Builder linkBuilder = Link.fromUri(href.asText());
final JsonNode rel = node.get("rel");
if (rel != null) {
linkBuilder.rel(rel.asText());
}
return linkBuilder.build();
}
项目:rest-schemagen
文件:LinkCreator.java
private void addHttpMethod(Builder builder, Scope scope) {
final List<Class<? extends Annotation>> httpMethodAnnotations = Arrays.asList(GET.class,
POST.class, PUT.class, DELETE.class);
final Method invokedMethod = scope.getInvokedMethod();
final Optional<Class<? extends Annotation>> httpMethod = httpMethodAnnotations.stream()
.filter(invokedMethod::isAnnotationPresent).findFirst();
if (httpMethod.isPresent()) {
builder.param(METHOD_PARAM_KEY, httpMethod.get().getSimpleName());
} else {
throw new IllegalArgumentException(
"LinkCreator: The method has to be annotated with one of: " + String.join(", ",
(Iterable<String>) httpMethodAnnotations.stream().map(
Class::getSimpleName).map(m -> '@' + m)::iterator));
}
}
项目:rest-schemagen
文件:LinkCreator.java
public static Builder setRelation(Relation relation, URI uri) {
requireNonNull(relation);
requireNonNull(uri);
Builder builder = Link.fromUri(uri).rel(relation.getName());
if (requireNonNull(relation).getType().isShouldBeSerialized()) {
builder.param("relType", relation.getType().getName());
builder.param("target", relation.getType().getSerializedName());
}
return builder;
}
项目:rest-schemagen
文件:LinkCreator.java
/**
* create a link for a resource method
*
* @param scopes
* list of Scope objects for every scope level
* @param relation
* relation of method
* @param linkFactoryContext
* the base URI for resolution of relative URIs and method and
* property checkers
* @return link with schema if applicable
*/
public Link createFor(List<Scope> scopes, Relation relation,
LinkFactoryContext linkFactoryContext) {
final Class<?> resourceClass = scopes.get(0).getInvokedClass();
UriBuilder uriBuilder = UriBuilder.fromResource(resourceClass);
Map<String, Object> pathParameters = new HashMap<>();
for (Scope scope : scopes) {
final Method method = scope.getInvokedMethod();
final Object[] parameters = scope.getParams();
if (method.isAnnotationPresent(Path.class)) {
uriBuilder.path(method.getDeclaringClass(), method.getName());
}
pathParameters.putAll(collectPathParameters(scope, parameters));
setQueryParameters(uriBuilder, scope, parameters);
}
URI uri = mergeUri(linkFactoryContext.getBaseUri(), uriBuilder, pathParameters);
Builder builder = setRelation(relation, uri);
addLinkProperties(scopes, builder);
detectMediaType(scopes, builder);
final Scope lastScopedMethod = Iterables.getLast(scopes);
addHttpMethod(builder, lastScopedMethod);
addSchemaIfNeeded(builder, lastScopedMethod, linkFactoryContext);
return builder.build();
}
项目:rest-schemagen
文件:LinkCreator.java
private void addLinkProperties(List<Scope> scopes, Builder builder) {
final LinkProperties properties = Iterables.getLast(scopes).getInvokedMethod()
.getAnnotation(LinkProperties.class);
if (properties != null) {
Stream.of(properties.value()).forEach(x -> builder.param(x.key(), x.value()));
}
}
项目:rest-schemagen
文件:LinkCreator.java
private void addSchemaIfNeeded(Builder builder, Scope method,
LinkFactoryContext linkFactoryContext) {
Optional<String> optionalInputSchema = jsonSchemaGenerator.createInputSchema(method,
linkFactoryContext.getFieldCheckerForSchema());
optionalInputSchema.ifPresent(s -> builder.param(SCHEMA_PARAM_KEY, s));
Optional<String> mt = detectMediaType(method.getInvokedMethod());
if (mt.isPresent() && MediaType.APPLICATION_JSON.equals(mt.get())) {
Optional<String> optionalOutputSchema = jsonSchemaGenerator.createOutputSchema(method,
linkFactoryContext.getFieldCheckerForSchema());
optionalOutputSchema.ifPresent(s -> builder.param(TARGET_SCHEMA_PARAM_KEY, s));
}
}
项目:rest-schemagen
文件:ExternalLinkFactory.java
public Link createFor(URI uri, Optional<String> schemaForLink, String relName) {
Objects.requireNonNull(uri);
Objects.requireNonNull(schemaForLink);
Objects.requireNonNull(relName);
Relation rel = Relation.of(relName, RelType.OTHER);
Builder linkBuilder = LinkCreator.setRelation(rel, uri);
schemaForLink.ifPresent(s -> linkBuilder.param(LinkCreator.SCHEMA_PARAM_KEY, s));
return linkBuilder.build();
}
项目:comms-router
文件:PaginationHelper.java
public PaginationHelper(
Supplier<UriBuilder> uriBuilderSupplier, Function<Link.Builder, Link> linkCreator) {
this.uriBuilderSupplier = uriBuilderSupplier;
this.linkCreator = linkCreator;
}
项目:minijax
文件:MinijaxRuntimeDelegate.java
@Override
public Builder createLinkBuilder() {
throw new UnsupportedOperationException();
}
项目:aml
文件:ResponseWrapper.java
@Override
public Builder getLinkBuilder(final String relation)
{
return delegate.getLinkBuilder(relation);
}
项目:aml
文件:PresentationsResource.java
@Override
public Builder getLinkBuilder(String relation) {
// TODO Auto-generated method stub
return null;
}
项目:aml
文件:ResponseWrapper.java
@Override
public Builder getLinkBuilder(final String relation)
{
return delegate.getLinkBuilder(relation);
}
项目:raml-module-builder
文件:ResponseImpl.java
@Override
public Builder getLinkBuilder(String relation) {
// TODO Auto-generated method stub
return null;
}
项目:olingo-jersey
文件:ResponseWrapper.java
@Override
public Builder getLinkBuilder(final String relation)
{
return delegate.getLinkBuilder(relation);
}
项目:putput
文件:ResponseWrapper.java
@Override
public Builder getLinkBuilder(final String relation)
{
return delegate.getLinkBuilder(relation);
}
项目:rest-schemagen
文件:LinkCreator.java
private void detectMediaType(Collection<Scope> scopes, Builder builder) {
detectMediaType(Iterables.getLast(scopes).getInvokedMethod()).ifPresent(mediatype -> builder
.param("mediaType", mediatype));
}
项目:raml-bpmn-talk
文件:ResponseWrapper.java
@Override
public Builder getLinkBuilder(final String relation)
{
return delegate.getLinkBuilder(relation);
}