Skip to content

io microsphere util Version

github-actions[bot] edited this page Mar 21, 2026 · 1 revision

Version

Type: Class | Module: microsphere-java-core | Package: io.microsphere.util | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/util/Version.java

Overview

Represents a version number composed of major, minor, and patch components.

This class provides methods to compare versions using standard comparison operators such as greater than, less than, and equal to. It also supports parsing version strings in the format "major.minor.patch". The supported version patterns :

- major
- major.minor
- major.minor.patch
- major.minor.patch-preRelease

See Semantic Versioning for more details.

Example Usage

`Version v1 = new Version(1, 2, 3);
Version v2 = Version.of("1.2.3");

// Comparison
boolean isEqual = v1.equals(v2); // true
boolean isGreaterThan = v1.isGreaterThan(Version.of("1.2.2")); // true
boolean isLessThan = v1.lt(Version.of("1.3.0")); // true

// Parsing from string
Version v3 = Version.of("2.0.0");

// Getting version from a class's manifest
Version versionFromManifest = Version.getVersion(MyClass.class);
`

Declaration

public class Version implements Comparable<Version>, Serializable

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.1.10-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 8 ✅ Compatible
Java 11 ✅ Compatible
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Examples

Version v1 = new Version(1, 2, 3);
Version v2 = Version.of("1.2.3");

// Comparison
boolean isEqual = v1.equals(v2); // true
boolean isGreaterThan = v1.isGreaterThan(Version.of("1.2.2")); // true
boolean isLessThan = v1.lt(Version.of("1.3.0")); // true

// Parsing from string
Version v3 = Version.of("2.0.0");

// Getting version from a class's manifest
Version versionFromManifest = Version.getVersion(MyClass.class);

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-java-core</artifactId>
    <version>${microsphere-java.version}</version>
</dependency>

Tip: Use the BOM (microsphere-java-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.util.Version;

API Reference

Public Methods

Method Description
getMajor The major version
getMinor The minor version
getPatch The patch
getPreRelease The pre-release
gt Current Version is greater than that
isGreaterThan Current Version is greater than that
ge Current Version is greater than or equal to that
isGreaterOrEqual Current Version is greater than or equal to that
lt Current Version is less than that
isLessThan Current Version is less than that
le Current Version is less than or equal to that
isLessOrEqual Current Version is less than or equal to that
eq Current Version is equal to that
compareTo
getVersion Compare pre-release
of The Operator : "Equal to" , whose symbol is : "="

Method Details

ge

public boolean ge(Version that)

Current Version is greater than or equal to that

isGreaterOrEqual

public boolean isGreaterOrEqual(Version that)

Current Version is greater than or equal to that

le

public boolean le(Version that)

Current Version is less than or equal to that

isLessOrEqual

public boolean isLessOrEqual(Version that)

Current Version is less than or equal to that

of

public static Operator of(String symbol)

The Operator : "Equal to" , whose symbol is : "=" / EQ(EQUAL) {


This documentation was auto-generated from the source code of microsphere-java.

Home

java-annotations

java-core

jdk-tools

lang-model

annotation-processor

java-test

Clone this wiki locally