org.n52.janmayen.function.Functions.castIfInstanceOf()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(163)

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

Functions.castIfInstanceOf介绍

[英]Returns a Function that casts it'S input argument to the specified type if it's the right type. The returned Optionaleither contains the casted input arguemnt or is empty.
[中]返回将其输入参数强制转换为指定类型(如果类型正确)的函数。返回的选项包含强制转换的输入参数arguemnt或为空。

代码示例

代码示例来源:origin: org.n52.iceland/iceland

private Set<OwsValue> getMediaTypes(Binding binding) {
  return binding.getKeys().stream()
      .map(Functions.castIfInstanceOf(MediaTypeBindingKey.class))
      .filter(Optional::isPresent).map(Optional::get)
      .map(MediaTypeBindingKey::getMediaType)
      .map(MediaType::toString)
      .map(OwsValue::new)
      .collect(toSet());
}

代码示例来源:origin: org.n52.arctic-sea/shetland

public static ReportObligationType getFlow(Extensions extensions) throws OwsExceptionReport {
    return extensions.getExtension(AqdConstants.EXTENSION_FLOW)
        .map(x -> x.getValue())
        .flatMap(Functions.castIfInstanceOf(SweText.class))
        .map(SweText::getValue)
        .map(ReportObligationType::from)
        .orElse(ReportObligationType.E2A);
  }
}

代码示例来源:origin: org.n52.shetland/shetland

public static ReportObligationType getFlow(Extensions extensions) throws OwsExceptionReport {
    return extensions.getExtension(AqdConstants.EXTENSION_FLOW)
        .map(x -> x.getValue())
        .flatMap(Functions.castIfInstanceOf(SweText.class))
        .map(SweText::getValue)
        .map(ReportObligationType::from)
        .orElse(ReportObligationType.E2A);
  }
}

代码示例来源:origin: org.n52.iceland/iceland

private Stream<OwsRequestMethod> getRequestMethods(Binding binding, OwsOperationKey operation) {
  Set<OwsDomain> constraints = createContentTypeDomains(getMediaTypes(binding));
  return binding.getKeys().stream()
      .map(Functions.castIfInstanceOf(PathBindingKey.class))
      .filter(Optional::isPresent).map(Optional::get)
      .map(PathBindingKey::getPath)
      .map(path -> URI.create(this.serviceURL + path))
      .flatMap(uri -> HTTPMethods.METHODS.stream()
      .filter(isMethodSupported(binding, operation))
      .map(method -> new OwsRequestMethod(uri, method, constraints)));
}

代码示例来源:origin: org.n52.series-api/proxy-dao

Optional<Set<DataEntity<?>>> values = Optional.ofNullable(obsValue)
    .map(ObservationValue::getValue)
    .flatMap(Functions.castIfInstanceOf(SweDataArrayValue.class))
    .map(SweDataArrayValue::getValue)
    .map(dataArray -> {
      SweAbstractDataComponent elementType = dataArray.getElementType();
      UnitEntity verticalUnit = Optional.ofNullable(elementType)
          .flatMap(Functions.castIfInstanceOf(SweDataRecord.class))
          .map(SweDataRecord::getFields)
          .filter(fields -> fields.size() == 2)

相关文章

微信公众号

最新文章

更多