maxChars method
Trims the String to have maximum n characters.
Example
String foo = 'esentis';
String newFoo = foo.maxChars(3); // 'esen';
Implementation
String maxChars(int n) {
if (isBlank || n >= length) {
return blankIfNull;
}
if (n <= 0) {
return '';
}
return substring(0, n);
}