当前位置: 首页>>代码示例>>Java>>正文


Java Builder.build方法代码示例

本文整理汇总了Java中javax.ws.rs.core.Link.Builder.build方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.build方法的具体用法?Java Builder.build怎么用?Java Builder.build使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.ws.rs.core.Link.Builder的用法示例。


在下文中一共展示了Builder.build方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserialize

import javax.ws.rs.core.Link.Builder; //导入方法依赖的package包/类
@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();
}
 
开发者ID:atgse,项目名称:sam,代码行数:19,代码来源:LinkDeserializer.java

示例2: createFor

import javax.ws.rs.core.Link.Builder; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:Mercateo,项目名称:rest-schemagen,代码行数:42,代码来源:LinkCreator.java

示例3: createFor

import javax.ws.rs.core.Link.Builder; //导入方法依赖的package包/类
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();
}
 
开发者ID:Mercateo,项目名称:rest-schemagen,代码行数:11,代码来源:ExternalLinkFactory.java


注:本文中的javax.ws.rs.core.Link.Builder.build方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。