feign.Util.emptyToNull()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(106)

本文整理了Java中feign.Util.emptyToNull()方法的一些代码示例,展示了Util.emptyToNull()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.emptyToNull()方法的具体详情如下:
包路径:feign.Util
类名称:Util
方法名:emptyToNull

Util.emptyToNull介绍

[英]Adapted from com.google.common.base.Strings#emptyToNull.
[中]改编自com。谷歌。常见的基础字符串#emptyToNull。

代码示例

代码示例来源:origin: com.netflix.feign/feign-core

  1. public HardCodedTarget(Class<T> type, String name, String url) {
  2. this.type = checkNotNull(type, "type");
  3. this.name = checkNotNull(emptyToNull(name), "name");
  4. this.url = checkNotNull(emptyToNull(url), "url");
  5. }

代码示例来源:origin: com.netflix.feign/feign-core

  1. EmptyTarget(Class<T> type, String name) {
  2. this.type = checkNotNull(type, "type");
  3. this.name = checkNotNull(emptyToNull(name), "name");
  4. }

代码示例来源:origin: SpringCloud/venus-cloud-feign

  1. private void parseProduces(MethodMetadata md, Method method,
  2. RequestMapping annotation) {
  3. String[] serverProduces = annotation.produces();
  4. String clientAccepts = serverProduces.length == 0 ? null
  5. : emptyToNull(serverProduces[0]);
  6. if (clientAccepts != null) {
  7. md.template().header(ACCEPT, clientAccepts);
  8. }
  9. }

代码示例来源:origin: org.springframework.cloud/spring-cloud-openfeign-core

  1. private void parseConsumes(MethodMetadata md, Method method,
  2. RequestMapping annotation) {
  3. String[] serverConsumes = annotation.consumes();
  4. String clientProduces = serverConsumes.length == 0 ? null
  5. : emptyToNull(serverConsumes[0]);
  6. if (clientProduces != null) {
  7. md.template().header(CONTENT_TYPE, clientProduces);
  8. }
  9. }

代码示例来源:origin: spring-cloud/spring-cloud-openfeign

  1. private void parseProduces(MethodMetadata md, Method method,
  2. RequestMapping annotation) {
  3. String[] serverProduces = annotation.produces();
  4. String clientAccepts = serverProduces.length == 0 ? null
  5. : emptyToNull(serverProduces[0]);
  6. if (clientAccepts != null) {
  7. md.template().header(ACCEPT, clientAccepts);
  8. }
  9. }

代码示例来源:origin: org.springframework.cloud/spring-cloud-openfeign-core

  1. private void parseProduces(MethodMetadata md, Method method,
  2. RequestMapping annotation) {
  3. String[] serverProduces = annotation.produces();
  4. String clientAccepts = serverProduces.length == 0 ? null
  5. : emptyToNull(serverProduces[0]);
  6. if (clientAccepts != null) {
  7. md.template().header(ACCEPT, clientAccepts);
  8. }
  9. }

代码示例来源:origin: spring-cloud/spring-cloud-openfeign

  1. private void parseConsumes(MethodMetadata md, Method method,
  2. RequestMapping annotation) {
  3. String[] serverConsumes = annotation.consumes();
  4. String clientProduces = serverConsumes.length == 0 ? null
  5. : emptyToNull(serverConsumes[0]);
  6. if (clientProduces != null) {
  7. md.template().header(CONTENT_TYPE, clientProduces);
  8. }
  9. }

代码示例来源:origin: ppdai-incubator/raptor

  1. private void parseProduces(MethodMetadata md, Method method,
  2. RequestMapping annotation) {
  3. String[] serverProduces = annotation.produces();
  4. String clientAccepts = serverProduces.length == 0 ? null
  5. : emptyToNull(serverProduces[0]);
  6. if (clientAccepts != null) {
  7. md.template().header(ACCEPT, clientAccepts);
  8. }
  9. }

代码示例来源:origin: SpringCloud/venus-cloud-feign

  1. private void parseConsumes(MethodMetadata md, Method method,
  2. RequestMapping annotation) {
  3. String[] serverConsumes = annotation.consumes();
  4. String clientProduces = serverConsumes.length == 0 ? null
  5. : emptyToNull(serverConsumes[0]);
  6. if (clientProduces != null) {
  7. md.template().header(CONTENT_TYPE, clientProduces);
  8. }
  9. }

代码示例来源:origin: ppdai-incubator/raptor

  1. private void parseConsumes(MethodMetadata md, Method method,
  2. RequestMapping annotation) {
  3. String[] serverConsumes = annotation.consumes();
  4. String clientProduces = serverConsumes.length == 0 ? null
  5. : emptyToNull(serverConsumes[0]);
  6. if (clientProduces != null) {
  7. md.template().header(CONTENT_TYPE, clientProduces);
  8. }
  9. }

代码示例来源:origin: spring-cloud/spring-cloud-openfeign

  1. @Override
  2. protected void processAnnotationOnClass(MethodMetadata data, Class<?> clz) {
  3. if (clz.getInterfaces().length == 0) {
  4. RequestMapping classAnnotation = findMergedAnnotation(clz,
  5. RequestMapping.class);
  6. if (classAnnotation != null) {
  7. // Prepend path from class annotation if specified
  8. if (classAnnotation.value().length > 0) {
  9. String pathValue = emptyToNull(classAnnotation.value()[0]);
  10. pathValue = resolve(pathValue);
  11. if (!pathValue.startsWith("/")) {
  12. pathValue = "/" + pathValue;
  13. }
  14. data.template().uri(pathValue);
  15. }
  16. }
  17. }
  18. }

代码示例来源:origin: org.springframework.cloud/spring-cloud-openfeign-core

  1. @Override
  2. protected void processAnnotationOnClass(MethodMetadata data, Class<?> clz) {
  3. if (clz.getInterfaces().length == 0) {
  4. RequestMapping classAnnotation = findMergedAnnotation(clz,
  5. RequestMapping.class);
  6. if (classAnnotation != null) {
  7. // Prepend path from class annotation if specified
  8. if (classAnnotation.value().length > 0) {
  9. String pathValue = emptyToNull(classAnnotation.value()[0]);
  10. pathValue = resolve(pathValue);
  11. if (!pathValue.startsWith("/")) {
  12. pathValue = "/" + pathValue;
  13. }
  14. data.template().uri(pathValue);
  15. }
  16. }
  17. }
  18. }

代码示例来源:origin: ppdai-incubator/raptor

  1. @Override
  2. protected void processAnnotationOnClass(MethodMetadata data, Class<?> clz) {
  3. if (clz.getInterfaces().length == 0) {
  4. RequestMapping classAnnotation = findMergedAnnotation(clz,
  5. RequestMapping.class);
  6. if (classAnnotation != null) {
  7. // Prepend path from class annotation if specified
  8. if (classAnnotation.value().length > 0) {
  9. String pathValue = emptyToNull(classAnnotation.value()[0]);
  10. pathValue = resolve(pathValue);
  11. if (!pathValue.startsWith("/")) {
  12. pathValue = "/" + pathValue;
  13. }
  14. data.template().insert(0, pathValue);
  15. }
  16. }
  17. }
  18. }

代码示例来源:origin: com.netflix.feign/feign-jaxrs

  1. private void handleProducesAnnotation(MethodMetadata data, Produces produces, String name) {
  2. String[] serverProduces = produces.value();
  3. String clientAccepts = serverProduces.length == 0 ? null : emptyToNull(serverProduces[0]);
  4. checkState(clientAccepts != null, "Produces.value() was empty on %s", name);
  5. data.template().header(ACCEPT, (String) null); // remove any previous produces
  6. data.template().header(ACCEPT, clientAccepts);
  7. }

代码示例来源:origin: com.netflix.feign/feign-jaxrs

  1. private void handleConsumesAnnotation(MethodMetadata data, Consumes consumes, String name) {
  2. String[] serverConsumes = consumes.value();
  3. String clientProduces = serverConsumes.length == 0 ? null : emptyToNull(serverConsumes[0]);
  4. checkState(clientProduces != null, "Consumes.value() was empty on %s", name);
  5. data.template().header(CONTENT_TYPE, (String) null); // remove any previous consumes
  6. data.template().header(CONTENT_TYPE, clientProduces);
  7. }

代码示例来源:origin: spring-cloud/spring-cloud-openfeign

  1. @Override
  2. public boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method) {
  3. int parameterIndex = context.getParameterIndex();
  4. Class<?> parameterType = method.getParameterTypes()[parameterIndex];
  5. MethodMetadata data = context.getMethodMetadata();
  6. if (Map.class.isAssignableFrom(parameterType)) {
  7. checkState(data.headerMapIndex() == null, "Header map can only be present once.");
  8. data.headerMapIndex(parameterIndex);
  9. return true;
  10. }
  11. String name = ANNOTATION.cast(annotation).value();
  12. checkState(emptyToNull(name) != null,
  13. "RequestHeader.value() was empty on parameter %s", parameterIndex);
  14. context.setParameterName(name);
  15. Collection<String> header = context.setTemplateParameter(name, data.template().headers().get(name));
  16. data.template().header(name, header);
  17. return true;
  18. }
  19. }

代码示例来源:origin: spring-cloud/spring-cloud-openfeign

  1. @Override
  2. public boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method) {
  3. String name = ANNOTATION.cast(annotation).value();
  4. checkState(emptyToNull(name) != null,
  5. "PathVariable annotation was empty on param %s.", context.getParameterIndex());
  6. context.setParameterName(name);
  7. MethodMetadata data = context.getMethodMetadata();
  8. String varName = '{' + name + '}';
  9. if (!data.template().url().contains(varName)
  10. && !searchMapValues(data.template().queries(), varName)
  11. && !searchMapValues(data.template().headers(), varName)) {
  12. data.formParams().add(name);
  13. }
  14. return true;
  15. }

代码示例来源:origin: org.springframework.cloud/spring-cloud-openfeign-core

  1. @Override
  2. public boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method) {
  3. int parameterIndex = context.getParameterIndex();
  4. Class<?> parameterType = method.getParameterTypes()[parameterIndex];
  5. MethodMetadata data = context.getMethodMetadata();
  6. if (Map.class.isAssignableFrom(parameterType)) {
  7. checkState(data.headerMapIndex() == null, "Header map can only be present once.");
  8. data.headerMapIndex(parameterIndex);
  9. return true;
  10. }
  11. String name = ANNOTATION.cast(annotation).value();
  12. checkState(emptyToNull(name) != null,
  13. "RequestHeader.value() was empty on parameter %s", parameterIndex);
  14. context.setParameterName(name);
  15. Collection<String> header = context.setTemplateParameter(name, data.template().headers().get(name));
  16. data.template().header(name, header);
  17. return true;
  18. }
  19. }

代码示例来源:origin: org.springframework.cloud/spring-cloud-openfeign-core

  1. @Override
  2. public boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method) {
  3. String name = ANNOTATION.cast(annotation).value();
  4. checkState(emptyToNull(name) != null,
  5. "PathVariable annotation was empty on param %s.", context.getParameterIndex());
  6. context.setParameterName(name);
  7. MethodMetadata data = context.getMethodMetadata();
  8. String varName = '{' + name + '}';
  9. if (!data.template().url().contains(varName)
  10. && !searchMapValues(data.template().queries(), varName)
  11. && !searchMapValues(data.template().headers(), varName)) {
  12. data.formParams().add(name);
  13. }
  14. return true;
  15. }

代码示例来源:origin: ppdai-incubator/raptor

  1. @Override
  2. public boolean processArgument(AnnotatedParameterContext context, Annotation annotation, Method method) {
  3. String name = ANNOTATION.cast(annotation).value();
  4. checkState(emptyToNull(name) != null,
  5. "PathVariable annotation was empty on param %s.", context.getParameterIndex());
  6. context.setParameterName(name);
  7. MethodMetadata data = context.getMethodMetadata();
  8. String varName = '{' + name + '}';
  9. if (!data.template().url().contains(varName)
  10. && !searchMapValues(data.template().queries(), varName)
  11. && !searchMapValues(data.template().headers(), varName)) {
  12. data.formParams().add(name);
  13. }
  14. return true;
  15. }

相关文章