Problem (@Nullable Token token, @Nullable Token prev, @Nullable Token next) { if (token == null) return null; switch (token.character) { case 'Y' -> { if (!hasNeighbor("w", prev, next)) { return new Problem(token, "week year", "year"); } } case 'M' -> { if (hasNeighbor("HhKk", prev, next) && !hasNeighbor("yd", prev, next)) { return new Problem(token, "month", "minute"); } } case 'm' -> { if (hasNeighbor("yd", prev, next) && !hasNeighbor("HhKk", prev, next)) { return new Problem(token, "minute", "month"); } } case 'D' -> { if (hasNeighbor("ML", prev, next)) { return new Problem(token, "day of year", "day of month"); } } case 'S' -> { if (hasNeighbor("m", prev, next)) { return new Problem(token, "milliseconds", "seconds"); } } } return null; }