com.yahoo.component.Version.toSpecification()方法的使用及代码示例

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

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

Version.toSpecification介绍

[英]Creates a version specification that only matches this version
[中]创建仅与此版本匹配的版本规范

代码示例

代码示例来源:origin: com.yahoo.vespa/documentapi

RoutableFactory getFactory(Version version) {
    VersionSpecification versionSpec = version.toSpecification();
    // Retrieve the factory with the highest version lower than or equal to actual version
    return factoryVersions.entrySet().stream()
        // Drop factories that have a higher version than actual version
        .filter(entry -> entry.getKey().compareTo(versionSpec) <= 0)
        // Get the factory with the highest version
        .max((entry1, entry2) -> entry1.getKey().compareTo(entry2.getKey()))
        .map(Map.Entry::getValue)
        // Return factory or null if no suitable factory found
        .orElse(null);
  }
}

代码示例来源:origin: com.yahoo.vespa/component

public ComponentSpecification toSpecification() {
  if (isAnonymous())
    throw new RuntimeException("Can't generate a specification for an anonymous component id.");
  return new ComponentSpecification(getName(),
      getVersion().toSpecification(), getNamespace());
}

相关文章