forked from LinShunKang/MyPerf4J
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8293482
commit a5cbb5e
Showing
6 changed files
with
44 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package cn.myperf4j.base; | ||
|
||
import cn.myperf4j.base.util.Logger; | ||
import cn.myperf4j.base.util.StrUtils; | ||
|
||
/** | ||
* Created by LinShunkang on 2020/08/09 | ||
*/ | ||
public final class Version { | ||
|
||
private static final String VERSION = getVersion(Version.class, ""); | ||
|
||
public static String getVersion() { | ||
return VERSION; | ||
} | ||
|
||
public static String getVersion(Class<?> cls, String defaultVersion) { | ||
try { | ||
String version = cls.getPackage().getImplementationVersion(); | ||
if (StrUtils.isBlank(version)) { | ||
version = cls.getPackage().getSpecificationVersion(); | ||
} | ||
return StrUtils.isBlank(version) ? defaultVersion : version; | ||
} catch (Throwable e) { | ||
Logger.error("Version.getVersion(" + cls + ", " + defaultVersion + "): catch Exception ", e); | ||
return defaultVersion; | ||
} | ||
} | ||
|
||
private Version() { | ||
//empty | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters