boolean (@NotNull String source, @NotNull String target) { int sourceStar = source.indexOf('*'); int targetStar = target.indexOf('*'); return (sourceStar < 0 && targetStar < 0) || (sourceStar == source.length() - 1 && targetStar == target.length() - 1); }