presto-spi/src/main/java/io/prestosql/spi/type/Chars.java/Chars/truncateToLengthAndTrimSpaces
class Chars:    public static Slice truncateToLengthAndTrimSpaces(Slice slice, int maxLength)
    {
        requireNonNull(slice, "slice is null");
        if (maxLength < 0) {
            throw new IllegalArgumentException("Max length must be greater or equal than zero");
        }
        return trimTrailingSpaces(truncateToLength(slice, maxLength));
    }