CharSequences
Utility methods for dealing with java.lang.CharSequence
.
<dependency>
<groupId>com.github.marschall</groupId>
<artifactId>charsequences</artifactId>
<version>0.8.0</version>
</dependency>
When dealing with CharSequence instead of String many convince methods are not available. While you could simply call toString() on the CharSequence this would defeat the purpose of using a CharSequence. This is project contains implementations of some of them.
- indexOf(char)
- indexOf(char, int)
- startsWith(CharSequence)
- trim()
- Integer.parseInt(String), no longer needed in Java 9 but still faster
- Long.parseLong(String), no longer needed in Java 9 but still faster
- String.split(String), limited, only a single character is allowed, not a full regex
- UUID.fromString(String), no intermediary allocation
- an empty implementation of
CharSequence
They avoid allocation where possible, check out the Javadoc for more information.