Class StringSimilarity

java.lang.Object
org.mockserver.matchers.StringSimilarity

public final class StringSimilarity extends Object
Deterministic string-similarity metrics used by FuzzyMatcher.

Implements the Jaro and Jaro-Winkler similarity algorithms directly (no external dependency) so the same pair of inputs always produces the same ratio between 0.0 (completely different) and 1.0 (identical).

Author:
jamesdbloom
  • Method Details

    • jaroWinkler

      public static double jaroWinkler(String first, String second)
      Jaro-Winkler similarity between two strings, in the range [0.0, 1.0].

      Two null or two empty strings are considered identical (1.0); comparing an empty/null string with a non-empty string yields 0.0.

    • jaro

      public static double jaro(String first, String second)
      Jaro similarity between two strings, in the range [0.0, 1.0].