package com.qianwen.core.tool.utils; import org.springframework.lang.Nullable; /* loaded from: blade-core-tool-9.3.0.0-SNAPSHOT.jar:org/springblade/core/tool/utils/Version.class */ public class Version { private static final String DELIMITER = "\\."; @Nullable private String version; private boolean complete = true; private Version() { } private Version(@Nullable String version) { this.version = version; } public Version incomplete() { this.complete = false; return this; } public static Version of(@Nullable String version) { return new Version(version); } public boolean eq(@Nullable String version) { return compare(version) == 0; } public boolean ne(@Nullable String version) { return compare(version) != 0; } public boolean gt(@Nullable String version) { return compare(version) > 0; } public boolean gte(@Nullable String version) { return compare(version) >= 0; } public boolean lt(@Nullable String version) { return compare(version) < 0; } public boolean lte(@Nullable String version) { return compare(version) <= 0; } private int compare(@Nullable String version) { return compare(this.version, version, this.complete); } private static int compare(@Nullable String v1, @Nullable String v2, boolean complete) { int min; if (v1 == v2) { return 0; } if (v1 == null) { return -1; } if (v2 == null) { return 1; } String v12 = v1.trim(); String v22 = v2.trim(); if (v12.equals(v22)) { return 0; } String[] v1s = v12.split(DELIMITER); String[] v2s = v22.split(DELIMITER); int v1sLen = v1s.length; int v2sLen = v2s.length; if (complete) { min = Math.max(v1sLen, v2sLen); } else { min = Math.min(v1sLen, v2sLen); } int len = min; for (int i = 0; i < len; i++) { String c1 = (len > v1sLen || null == v1s[i]) ? StringPool.EMPTY : v1s[i]; String c2 = (len > v2sLen || null == v2s[i]) ? StringPool.EMPTY : v2s[i]; int result = c1.compareTo(c2); if (result != 0) { return result; } } return 0; } }