All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.slf4j.helpers.Slf4jEnvUtil Maven / Gradle / Ivy

There is a newer version: 2.1.0-alpha1
Show newest version
package org.slf4j.helpers;

import java.lang.module.ModuleDescriptor;
import java.util.Optional;

public class Slf4jEnvUtil {


    /**
     * 

Returns the current version of logback, or null if data is not * available. *

* * @return current version or null if missing version data * @since 1.3.0 */ static public String slf4jVersion() { String moduleVersion = slf4jVersionByModule(); if(moduleVersion != null) return moduleVersion; Package pkg = Slf4jEnvUtil.class.getPackage(); if(pkg == null) { return null; } final String pkgVersion = pkg.getImplementationVersion(); return pkgVersion; } /** *

Returns the current version of logback via class.getModule() or null if data is not * available. *

* * @since 1.3.0 * @return current version or null if missing version data */ static private String slf4jVersionByModule() { Module module = Slf4jEnvUtil.class.getModule(); if (module == null) return null; ModuleDescriptor md = module.getDescriptor(); if (md == null) return null; Optional opt = md.rawVersion(); return opt.orElse(null); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy