Repository navigation
io microsphere util VersionUtils
Type: Class | Module: microsphere-java-core | Package: io.microsphere.util | Since: 1.0.0
Source:
microsphere-java-core/src/main/java/io/microsphere/util/VersionUtils.java
The utility class for version
public abstract class VersionUtils implements UtilsAuthor: Mercy
-
Introduced in:
1.0.0 -
Current Project Version:
0.3.20-SNAPSHOT
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 |
VersionUtils.testCurrentJavaVersion("=", VersionUtils.JAVA_VERSION_8); // true if current Java version is 8
VersionUtils.testCurrentJavaVersion(">", VersionUtils.JAVA_VERSION_8); // true if current Java version is higher than 8
VersionUtils.testCurrentJavaVersion("<", VersionUtils.JAVA_VERSION_11); // true if current Java version is lower than 11VersionUtils.testVersion("1.8", "=", "1.8.0") == true
VersionUtils.testVersion("1.8", ">=", "1.7") == true
VersionUtils.testVersion("1.8", "<=", "1.7") == false
VersionUtils.testVersion("1.8", "<", "1.7") == false
VersionUtils.testVersion("1.8", ">", "1.7") == trueVersion v1 = Version.of("1.8.0");
Version v2 = Version.of("1.7.0");
Version.Operator eq = Version.Operator.of("="); // Equals
Version.Operator gt = Version.Operator.of(">"); // Greater than
Version.Operator lt = Version.Operator.of("<"); // Less than
testVersion(v1, eq, v1); // true
testVersion(v1, gt, v2); // true
testVersion(v2, lt, v1); // trueAdd 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 io.microsphere.util.VersionUtils;| Method | Description |
|---|---|
testCurrentJavaVersion |
The latest SourceVersion Java Release Version
|
testCurrentJavaVersion |
Determine whether #CURRENT_JAVA_VERSION current Java version matches the specified version |
testVersion |
Determines whether the specified base version matches the compared version based on the given operator symbol. |
testVersion |
Determine whether the base version matches the compared version |
public static boolean testCurrentJavaVersion(@Nonnull String operatorSymbol, @Nullable Version comparedVersion)The latest SourceVersion Java Release Version
/
public static final SourceVersion LATEST_JAVA_VERSION = latest();
/**
The Version instance for current Java Version
/
public static final Version CURRENT_JAVA_VERSION = ofVersion(currentJavaMajorVersion());
/**
The Version instance for Java 8
/
public static final Version JAVA_VERSION_8 = ofVersion(8);
/**
The Version instance for Java 9
/
public static final Version JAVA_VERSION_9 = ofVersion(9);
/**
The Version instance for Java 10
/
public static final Version JAVA_VERSION_10 = ofVersion(10);
/**
The Version instance for Java 11
/
public static final Version JAVA_VERSION_11 = ofVersion(11);
/**
The Version instance for Java 12
/
public static final Version JAVA_VERSION_12 = ofVersion(12);
/**
The Version instance for Java 13
/
public static final Version JAVA_VERSION_13 = ofVersion(13);
/**
The Version instance for Java 14
/
public static final Version JAVA_VERSION_14 = ofVersion(14);
/**
The Version instance for Java 15
/
public static final Version JAVA_VERSION_15 = ofVersion(15);
/**
The Version instance for Java 16
/
public static final Version JAVA_VERSION_16 = ofVersion(16);
/**
The Version instance for Java 17
/
public static final Version JAVA_VERSION_17 = ofVersion(17);
/**
The Version instance for Java 18
/
public static final Version JAVA_VERSION_18 = ofVersion(18);
/**
The Version instance for Java 19
/
public static final Version JAVA_VERSION_19 = ofVersion(19);
/**
The Version instance for Java 20
/
public static final Version JAVA_VERSION_20 = ofVersion(20);
/**
The Version instance for Java 21
/
public static final Version JAVA_VERSION_21 = ofVersion(21);
/**
The Version instance for Java 22
/
public static final Version JAVA_VERSION_22 = ofVersion(22);
/**
The Version instance for Java 23
/
public static final Version JAVA_VERSION_23 = ofVersion(23);
/**
The Version instance for Java 24
/
public static final Version JAVA_VERSION_24 = ofVersion(24);
/** Determines whether the current Java version matches the specified version based on the given operator symbol.
-
=- Equal to -
>- Greater than -
>=- Greater than or equal to - ``VersionUtils.testCurrentJavaVersion("=", VersionUtils.JAVA_VERSION_8); // true if current Java version is 8 VersionUtils.testCurrentJavaVersion(">", VersionUtils.JAVA_VERSION_8); // true if current Java version is higher than 8 VersionUtils.testCurrentJavaVersion("
public static boolean testCurrentJavaVersion(@Nullable Version.Operator versionOperator, @Nullable Version comparedVersion)Determine whether #CURRENT_JAVA_VERSION current Java version matches the specified version
public static boolean testVersion(@Nullable String baseVersion, @Nullable String operatorSymbol, @Nullable String comparedVersion)Determines whether the specified base version matches the compared version based on the given operator symbol.
-
=- Equal to -
>- Greater than -
>=- Greater than or equal to - ``VersionUtils.testVersion("1.8", "=", "1.8.0") == true VersionUtils.testVersion("1.8", ">=", "1.7") == true VersionUtils.testVersion("1.8", "", "1.7") == true `
public static boolean testVersion(@Nullable Version baseVersion, @Nullable Version.Operator versionOperator, @Nullable Version comparedVersion)Determine whether the base version matches the compared version
Version
This documentation was auto-generated from the source code of microsphere-java.
annotation-processor
- ConfigurationPropertyAnnotationProcessor
- ConfigurationPropertyJSONElementVisitor
- FilerProcessor
- ResourceProcessor
annotation-test
java-annotations
java-core
- ACLLoggerFactory
- AbstractArtifactResourceResolver
- AbstractConverter
- AbstractDeque
- AbstractEventDispatcher
- AbstractLogger
- AbstractSerializer
- AbstractURLClassPathHandle
- AccessibleObjectUtils
- AdditionalMetadataResourceConfigurationPropertyLoader
- AnnotationUtils
- ArchiveFileArtifactResourceResolver
- ArrayEnumeration
- ArrayStack
- ArrayUtils
- Artifact
- ArtifactDetector
- ArtifactResourceResolver
- Assert
- BannedArtifactClassLoadingExecutor
- BeanMetadata
- BeanProperty
- BeanUtils
- BooleanSerializer
- ByteArrayToObjectConverter
- ByteSerializer
- CharSequenceComparator
- CharSequenceUtils
- CharacterSerializer
- CharsetUtils
- ClassDataRepository
- ClassDefinition
- ClassFileJarEntryFilter
- ClassFilter
- ClassLoaderUtils
- ClassPathResourceConfigurationPropertyLoader
- ClassPathUtils
- ClassUtils
- ClassicProcessIdResolver
- ClassicURLClassPathHandle
- CollectionUtils
- Compatible
- CompositeSubProtocolURLConnectionFactory
- CompositeURLStreamHandlerFactory
- ConditionalEventListener
- ConfigurationProperty
- ConfigurationPropertyGenerator
- ConfigurationPropertyLoader
- ConfigurationPropertyReader
- Configurer
- ConsoleURLConnection
- ConstantPoolUtils
- Constants
- ConstructorDefinition
- ConstructorUtils
- Converter
- Converters
- CustomizedThreadFactory
- DefaultConfigurationPropertyGenerator
- DefaultConfigurationPropertyReader
- DefaultDeserializer
- DefaultEntry
- DefaultSerializer
- DelegatingBlockingQueue
- DelegatingDeque
- DelegatingIterator
- DelegatingQueue
- DelegatingScheduledExecutorService
- DelegatingURLConnection
- DelegatingURLStreamHandlerFactory
- DelegatingWrapper
- Deprecation
- Deserializer
- Deserializers
- DirectEventDispatcher
- DirectoryFileFilter
- DoubleSerializer
- EmptyDeque
- EmptyIterable
- EmptyIterator
- EnumSerializer
- EnumerationIteratorAdapter
- EnumerationUtils
- Event
- EventDispatcher
- EventListener
- ExceptionUtils
- ExecutableDefinition
- ExecutableUtils
- ExecutorUtils
- ExtendableProtocolURLStreamHandler
- FastByteArrayInputStream
- FastByteArrayOutputStream
- FieldDefinition
- FieldUtils
- FileChangedEvent
- FileChangedListener
- FileConstants
- FileExtensionFilter
- FileUtils
- FileWatchService
- Files
- Filter
- FilterOperator
- FilterUtils
- FloatSerializer
- FormatUtils
- Functional
- GenericEvent
- GenericEventListener
- Handler
- Handler
- HierarchicalClassComparator
- IOFileFilter
- IOUtils
- ImmutableEntry
- IntegerSerializer
- IterableAdapter
- IterableUtils
- Iterators
- JDKLoggerFactory
- JSON
- JSONArray
- JSONException
- JSONObject
- JSONStringer
- JSONTokener
- JSONUtils
- JarEntryFilter
- JarUtils
- JavaType
- JmxUtils
- LambdaUtils
- ListUtils
- Listenable
- Lists
- Logger
- LoggerFactory
- LoggerUtils
- LoggingFileChangedListener
- LongSerializer
- MBeanAttribute
- MBeanAttributeInfoBuilder
- MBeanConstructorInfoBuilder
- MBeanDescribableBuilder
- MBeanExecutableInfoBuilder
- MBeanFeatureInfoBuilder
- MBeanInfoBuilder
- MBeanNotificationInfoBuilder
- MBeanOperationInfoBuilder
- MBeanParameterInfoBuilder
- ManagementUtils
- ManifestArtifactResourceResolver
- MapToPropertiesConverter
- MapUtils
- Maps
- MavenArtifact
- MavenArtifactResourceResolver
- MemberDefinition
- MemberUtils
- MetadataResourceConfigurationPropertyLoader
- MethodDefinition
- MethodHandleUtils
- MethodHandlesLookupUtils
- MethodUtils
- ModernProcessIdResolver
- ModernURLClassPathHandle
- Modifier
- MultiValueConverter
- MultipleType
- MutableInteger
- MutableURLStreamHandlerFactory
- NameFileFilter
- NoOpLogger
- NoOpLoggerFactory
- NoOpURLClassPathHandle
- NumberToByteConverter
- NumberToCharacterConverter
- NumberToDoubleConverter
- NumberToFloatConverter
- NumberToIntegerConverter
- NumberToLongConverter
- NumberToShortConverter
- NumberUtils
- ObjectToBooleanConverter
- ObjectToByteArrayConverter
- ObjectToByteConverter
- ObjectToCharacterConverter
- ObjectToDoubleConverter
- ObjectToFloatConverter
- ObjectToIntegerConverter
- ObjectToLongConverter
- ObjectToOptionalConverter
- ObjectToShortConverter
- ObjectToStringConverter
- ObjectUtils
- PackageNameClassFilter
- PackageNameClassNameFilter
- ParallelEventDispatcher
- ParameterizedTypeImpl
- PathConstants
- Predicates
- Prioritized
- PriorityComparator
- ProcessExecutor
- ProcessIdResolver
- ProcessManager
- PropertiesToStringConverter
- PropertiesUtils
- PropertyConstants
- PropertyResourceBundleControl
- PropertyResourceBundleUtils
- ProtocolConstants
- ProxyUtils
- QueueUtils
- ReadOnlyIterator
- ReflectionUtils
- ReflectiveConfigurationPropertyGenerator
- ReflectiveDefinition
- ResourceConstants
- ReversedDeque
- Scanner
- SecurityUtils
- SeparatorConstants
- Serializer
- Serializers
- ServiceLoaderURLStreamHandlerFactory
- ServiceLoaderUtils
- ServiceLoadingURLClassPathHandle
- SetUtils
- Sets
- Sfl4jLoggerFactory
- ShortSerializer
- ShutdownHookCallbacksThread
- ShutdownHookUtils
- SimpleClassScanner
- SimpleFileScanner
- SimpleJarEntryScanner
- SingletonDeque
- SingletonEnumeration
- SingletonIterator
- SizeUtils
- StackTraceUtils
- StandardFileWatchService
- StandardURLStreamHandlerFactory
- StopWatch
- StreamArtifactResourceResolver
- Streams
- StringBuilderWriter
- StringConverter
- StringDeserializer
- StringSerializer
- StringToArrayConverter
- StringToBlockingDequeConverter
- StringToBlockingQueueConverter
- StringToBooleanConverter
- StringToByteConverter
- StringToCharArrayConverter
- StringToCharacterConverter
- StringToClassConverter
- StringToCollectionConverter
- StringToDequeConverter
- StringToDoubleConverter
- StringToDurationConverter
- StringToFloatConverter
- StringToInputStreamConverter
- StringToIntegerConverter
- StringToIterableConverter
- StringToListConverter
- StringToLongConverter
- StringToMultiValueConverter
- StringToNavigableSetConverter
- StringToQueueConverter
- StringToSetConverter
- StringToShortConverter
- StringToSortedSetConverter
- StringToStringConverter
- StringToTransferQueueConverter
- StringUtils
- SubProtocolURLConnectionFactory
- SymbolConstants
- SystemUtils
- ThrowableAction
- ThrowableBiConsumer
- ThrowableBiFunction
- ThrowableConsumer
- ThrowableFunction
- ThrowableSupplier
- ThrowableUtils
- TrueClassFilter
- TrueFileFilter
- TypeArgument
- TypeFinder
- TypeUtils
- URLClassPathHandle
- URLUtils
- UnmodifiableDeque
- UnmodifiableIterator
- UnmodifiableQueue
- UnsafeUtils
- Utils
- ValueHolder
- Version
- VersionUtils
- VirtualMachineProcessIdResolver
- Wrapper
- WrapperProcessor
java-test
- Ancestor
- ArrayTypeModel
- CollectionTypeModel
- Color
- ConfigurationPropertyModel
- DefaultTestService
- GenericTestService
- MapTypeModel
- Model
- Parent
- PrimitiveTypeModel
- SimpleTypeModel
- StringArrayList
- TestAnnotation
- TestService
- TestServiceImpl
jdk-tools
lang-model