splitToList should return ImmutableList
See original GitHub issueI find myself constantly writing things like this:
ImmutableList<String> parts = ImmutableList.copyOf(Splitter.on("/").split(path));
I’d like to use splitToList
but it doesn’t return an immutable list.
I was wondering how the Guava team justifies this method returning a mutable list. What’s the use case for this list being mutable?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Splitter (Guava: Google Core Libraries for Java 19.0 API)
Splits sequence into string components and returns them as an immutable list. Splitter · trimResults(). Returns a splitter that behaves equivalently to this ......
Read more >Splitter splitToList() method | Guava | Java - GeeksforGeeks
The method splitToList(CharSequence sequence) splits sequence into string components and returns them as an immutable list. Syntax:.
Read more >Example usage for com.google.common.base Splitter splitToList
@CheckReturnValue @Beta public List<String> splitToList(CharSequence ... Splits sequence into string components and returns them as an immutable list.
Read more >Why does List.of() in Java not return a typed immutable list?
elements) should return a ImmutableList that extends List . This way the user can decide if he cares to show this fact of...
Read more >com.google.common.base.Splitter.onPattern java code ...
splitToList is @Beta, so we avoid it. return ImmutableList. ... <p>Note: There will be a trailing empty string if the input string ends...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
(Or as a good enough second option, can we at least get
splitToImmutableList
as an alternative?)I’m afraid I’ll probably be making a
BetterSplitter
class which just has the method return the right list type in the first place and banning use of Guava’s one in our codebase.