Class BasicUtils


  • public class BasicUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int compareSemanticVersions​(java.lang.String compared, java.lang.String basic)
      Compares two semantic versions following SemVer precedence rules.
      static java.lang.String truncateString​(java.lang.String string, int limit, java.lang.String truncateReplacement)
      Truncates string to the specified limit.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • truncateString

        @Nonnull
        public static java.lang.String truncateString​(@Nonnull
                                                      java.lang.String string,
                                                      int limit,
                                                      @Nullable
                                                      java.lang.String truncateReplacement)
        Truncates string to the specified limit. If string length exceeds the limit, it will be cut and the truncateReplacement will be appended.
        Parameters:
        string - string to truncate
        limit - maximum allowed length
        truncateReplacement - string to append if truncation happens, defaults to CommonConstants.DEFAULT_TRUNCATE_REPLACEMENT if null
        Returns:
        truncated string if original length exceeds the limit, original string otherwise
      • compareSemanticVersions

        public static int compareSemanticVersions​(@Nonnull
                                                  java.lang.String compared,
                                                  @Nonnull
                                                  java.lang.String basic)
        Compares two semantic versions following SemVer precedence rules. Returns a negative integer, zero, or a positive integer if the first argument is less than, equal to, or greater than the second respectively.
        Parameters:
        compared - value for comparison
        basic - value to compare with
        Returns:
        -1 if compared value less than basic, 0 if compared value equals basic, 1 if compared value greater than basic