java.lang.Package.getImplementationVersion()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(288)

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

Package.getImplementationVersion介绍

[英]Returns the version of the implementation of this package, or null if this is unknown. The format of this string is unspecified.
[中]返回此包的实现版本,如果未知,则返回null。此字符串的格式未指定。

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Return the full version string of the present Spring codebase,
 * or {@code null} if it cannot be determined.
 * @see Package#getImplementationVersion()
 */
@Nullable
public static String getVersion() {
  Package pkg = SpringVersion.class.getPackage();
  return (pkg != null ? pkg.getImplementationVersion() : null);
}

代码示例来源:origin: ch.qos.logback/logback-classic

String getImplementationVersion(Class type) {
  if (type == null) {
    return "na";
  }
  Package aPackage = type.getPackage();
  if (aPackage != null) {
    String v = aPackage.getImplementationVersion();
    if (v == null) {
      return "na";
    } else {
      return v;
    }
  }
  return "na";
}

代码示例来源:origin: apache/incubator-druid

private String getDruidVersion()
{
 return Status.class.getPackage().getImplementationVersion();
}

代码示例来源:origin: pxb1988/dex2jar

@Override
protected String getVersionString() {
  return "reader-" + DexFileReader.class.getPackage().getImplementationVersion() + ", translator-"
      + Dex2jar.class.getPackage().getImplementationVersion() + ", ir-"
      + ET.class.getPackage().getImplementationVersion();
}

代码示例来源:origin: checkstyle/checkstyle

/**
 * Returns the version string printed when the user requests version help (--version or -V).
 * @return a version string based on the package implementation version
 */
private static String getVersionString() {
  return "Checkstyle version: " + Main.class.getPackage().getImplementationVersion();
}

代码示例来源:origin: hibernate/hibernate-orm

public static String getVersionString() {
    if ( version == null ) {
      version = Version.class.getPackage().getImplementationVersion();
      if ( version == null ) {
        version = "[WORKING]";
      }
    }
    return version;
  }
}

代码示例来源:origin: prestodb/presto

public boolean showVersionIfRequested()
  {
    if (version) {
      String clientVersion = Presto.class.getPackage().getImplementationVersion();
      System.out.println("Presto CLI " + firstNonNull(clientVersion, "(version unknown)"));
    }
    return version;
  }
}

代码示例来源:origin: baomidou/mybatis-plus

public static String getVersion() {
  Package pkg = MybatisPlusVersion.class.getPackage();
  return (pkg != null ? pkg.getImplementationVersion() : null);
}

代码示例来源:origin: pxb1988/dex2jar

private static void doAddVersion(List<String> vs, String pkg, Class<?> clz) {
  try {
    vs.add(pkg + "-" + clz.getPackage().getImplementationVersion());
  } catch (Exception ignore) {
    // ignored
  }
}

代码示例来源:origin: spring-projects/spring-security

public static String getVersion() {
  Package pkg = SpringSecurityCoreVersion.class.getPackage();
  return (pkg != null ? pkg.getImplementationVersion() : null);
}

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

/**
 * Return the full version string of the present Spring codebase,
 * or {@code null} if it cannot be determined.
 * @see Package#getImplementationVersion()
 */
@Nullable
public static String getVersion() {
  Package pkg = SpringVersion.class.getPackage();
  return (pkg != null ? pkg.getImplementationVersion() : null);
}

代码示例来源:origin: pxb1988/dex2jar

protected String getVersionString() {
  return getClass().getPackage().getImplementationVersion();
}

代码示例来源:origin: checkstyle/checkstyle

@Override
public void auditStarted(AuditEvent event) {
  writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
  final String version = XMLLogger.class.getPackage().getImplementationVersion();
  writer.println("<checkstyle version=\"" + version + "\">");
}

代码示例来源:origin: apache/hive

String getApplicationTitle() {
 Package pack = BeeLine.class.getPackage();
 return loc("app-introduction", new Object[] { "Beeline",
   pack.getImplementationVersion() == null ? "???" : pack.getImplementationVersion(),
   "Apache Hive",
   // getManifestAttribute ("Specification-Title"),
   // getManifestAttribute ("Implementation-Version"),
   // getManifestAttribute ("Implementation-ReleaseDate"),
   // getManifestAttribute ("Implementation-Vendor"),
   // getManifestAttribute ("Implementation-License"),
 });
}

代码示例来源:origin: prestodb/presto

@Test(groups = CLI, timeOut = TIMEOUT)
public void shouldDisplayVersion()
    throws IOException
{
  launchPrestoCli("--version");
  String version = firstNonNull(Presto.class.getPackage().getImplementationVersion(), "(version unknown)");
  assertThat(presto.readRemainingOutputLines()).containsExactly("Presto CLI " + version);
}

代码示例来源:origin: spring-projects/spring-security

public SecurityNamespaceHandler() {
  String coreVersion = SpringSecurityCoreVersion.getVersion();
  Package pkg = SpringSecurityCoreVersion.class.getPackage();
  if (pkg == null || coreVersion == null) {
    logger.info("Couldn't determine package version information.");
    return;
  }
  String version = pkg.getImplementationVersion();
  logger.info("Spring Security 'config' module version is " + version);
  if (version.compareTo(coreVersion) != 0) {
    logger.error("You are running with different versions of the Spring Security 'core' and 'config' modules");
  }
}

代码示例来源:origin: apache/incubator-druid

/**
  * Load the unique extensions and return their implementation-versions
  *
  * @return map of extensions loaded with their respective implementation versions.
  */
 private List<ModuleVersion> getExtensionVersions(Collection<DruidModule> druidModules)
 {
  List<ModuleVersion> moduleVersions = new ArrayList<>();
  for (DruidModule module : druidModules) {
   String artifact = module.getClass().getPackage().getImplementationTitle();
   String version = module.getClass().getPackage().getImplementationVersion();
   moduleVersions.add(new ModuleVersion(module.getClass().getCanonicalName(), artifact, version));
  }
  return moduleVersions;
 }
}

代码示例来源:origin: alibaba/Sentinel

public static String getVersion(String defaultVersion) {
  try {
    String version = VersionUtil.class.getPackage().getImplementationVersion();
    return StringUtil.isBlank(version) ? defaultVersion : version;
  } catch (Throwable e) {
    RecordLog.warn("Using default version, ignore exception", e);
    return defaultVersion;
  }
}

代码示例来源:origin: gocd/gocd

public static void main(String... args) {
  if (shouldRedirectStdOutAndErr()) {
    redirectStdOutAndErr();
  }
  log("Starting process: ");
  log("  Working directory    : " + System.getProperty("user.dir"));
  log("  Application arguments: " + Arrays.asList(args));
  log("           GoCD Version: " + Boot.class.getPackage().getImplementationVersion());
  if (shouldLogJVMArgsAndEnvVars()) {
    log("  JVM arguments        : " + jvmArgs());
    log("         JVM properties: " + System.getProperties());
    log("  Environment Variables: " + System.getenv());
  }
  new Boot(args).run();
}

代码示例来源:origin: testcontainers/testcontainers-java

@Test
public void shouldCallActualMockserverVersion() throws Exception {
  String actualVersion = MockServerClient.class.getPackage().getImplementationVersion();
  try (MockServerContainer mockServer = new MockServerContainer(actualVersion)) {
    mockServer.start();
    String expectedBody = "Hello World!";
    assertThat("MockServer returns correct result",
      responseFromMockserver(mockServer, expectedBody, "/hello"),
      containsString(expectedBody)
    );
  }
}

相关文章