-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve null safety in Stream creation #155
Conversation
* [#150] API refactoring and improvements: a) Rename: flatMapToKey/flatMapToValue/mapToKey/mapToValue To: flatMapKeys/flatMapValues/mapKeys/mapValues c) Rename flatMapKeyValue/mapKeyValue/filterKeyValue/removeKeyValue/peekKeyVale/forKeyValue To: flatMap/map/filter/remove/peek/forEach c) Rename grouping/groupingBy/groupingTo/joining To: groupTo/join d) Add groupBy to StreamEx/EntryStreamEx e) Push up flatMapToEntry/mapToEntry from StreamEx to AbstractStreamEx f) Change: <K, T> EntryStream<K, T> mapToEntry(Function<? super T, K> mapper) To: <K, V> EntryStream<K, V> mapToEntry(Function<? super T, ? extends Map.Entry<K, V>> mapper)
* [#150] API refactoring and improvements: * Rename: flatMapToKey/flatMapToValue/mapToKey/mapToValue To: flatMapKeys/flatMapValues/mapKeys/mapValues * Rename flatMapKeyValue/mapKeyValue/filterKeyValue/removeKeyValue/peekKeyVale/forKeyValue To: flatMap/map/filter/remove/peek/forEach * Rename grouping/groupingBy/groupingTo/joining To: groupTo/join * Add groupBy to StreamEx/EntryStreamEx * Push up flatMapToEntry/mapToEntry from StreamEx to AbstractStreamEx * Change: <K, T> EntryStream<K, T> mapToEntry(Function<? super T, K> mapper) To: <K, V> EntryStream<K, V> mapToEntry(Function<? super T, ? extends Map.Entry<K, V>> mapper)
* [#150] API refactoring and improvements: * Rename: flatMapToKey/flatMapToValue/mapToKey/mapToValue To: flatMapKeys/flatMapValues/mapKeys/mapValues * Rename flatMapKeyValue/mapKeyValue/filterKeyValue/removeKeyValue/peekKeyVale/forKeyValue To: flatMap/map/filter/remove/peek/forEach * Rename grouping/groupingBy/groupingTo/joining To: groupTo/join * Add groupBy to StreamEx/EntryStreamEx * Push up flatMapToEntry/mapToEntry from StreamEx to AbstractStreamEx * Change: <K, T> EntryStream<K, T> mapToEntry(Function<? super T, K> mapper) To: <K, V> EntryStream<K, V> mapToEntry(Function<? super T, ? extends Map.Entry<K, V>> mapper)
* Improve Null Safety * Rename: flatMapToKey/flatMapToValue/mapToKey/mapToValue To: flatMapKeys/flatMapValues/mapKeys/mapValues * Rename flatMapKeyValue/mapKeyValue/filterKeyValue/removeKeyValue/peekKeyVale/forKeyValue To: flatMap/map/filter/remove/peek/forEach * Rename grouping/groupingBy/groupingTo/joining To: groupTo/join * Add groupBy to StreamEx/EntryStreamEx * Push up flatMapToEntry/mapToEntry from StreamEx to AbstractStreamEx * Change: <K, T> EntryStream<K, T> mapToEntry(Function<? super T, K> mapper) To: <K, V> EntryStream<K, V> mapToEntry(Function<? super T, ? extends Map.Entry<K, V>> mapper) * Change: mapLastOrElse(Function<? super T, ? extends R> notLastMapper, Function<? super T, ? extends R> lastMapper) To: mapLastOrElse(Function<? super T, ? extends R> lastMapper, Function<? super T, ? extends R> notLastMapper)
* Improve Null Safety * Rename: `flatMapToKey/flatMapToValue/mapToKey/mapToValue` To: `flatMapKeys/flatMapValues/mapKeys/mapValues` * Rename `flatMapKeyValue/mapKeyValue/filterKeyValue/removeKeyValue/peekKeyVale/forKeyValue` To: `flatMap/map/filter/remove/peek/forEach` * Rename `grouping/groupingBy/groupingTo/joining/forPairs` To: `groupTo/join/forEachPair` * Add `groupBy` to `StreamEx/EntryStreamEx` * Push up `flatMapToEntry/mapToEntry` from `StreamEx` to `AbstractStreamEx` * Rename `EntryStream<T, V> mapToEntry(Function<? super T, ? extends V> valueMapper)` To: `EntryStream<T, V> mapToEntryByVal(Function<? super T, ? extends V> valueMapper)` * Add `EntryStream<K, T> mapToEntryByKey(Function<? super T, K> keyMapper)` * Change***: `mapLastOrElse(Function<? super T, ? extends R> notLastMapper, Function<? super T, ? extends R> lastMapper)` To: `mapLastOrElse(Function<? super T, ? extends R> lastMapper, Function<? super T, ? extends R> notLastMapper)`
* Improve Null Safety * Rename: `flatMapToKey/flatMapToValue/mapToKey/mapToValue` To: `flatMapKeys/flatMapValues/mapKeys/mapValues` * Rename `flatMapKeyValue/mapKeyValue/filterKeyValue/removeKeyValue/peekKeyVale/forKeyValue` To: `flatMap/map/filter/remove/peek/forEach` * Rename `grouping/groupingBy/groupingTo/joining/forPairs` To: `groupTo/join/forEachPair` * Add `groupBy` to `StreamEx/EntryStreamEx` * Push up `flatMapToEntry/mapToEntry` from `StreamEx` to `AbstractStreamEx` * Rename `EntryStream<T, V> mapToEntry(Function<? super T, ? extends V> valueMapper)` To: `EntryStream<T, V> mapToEntryByVal(Function<? super T, ? extends V> valueMapper)` * Add `EntryStream<K, T> mapToEntryByKey(Function<? super T, K> keyMapper)` * Change***: `mapLastOrElse(Function<? super T, ? extends R> notLastMapper, Function<? super T, ? extends R> lastMapper)` To: `mapLastOrElse(Function<? super T, ? extends R> lastMapper, Function<? super T, ? extends R> notLastMapper)`
I deliberately follow notnull fail-fast policy. Collection/array object should not be null in the most of the cases. If it's null, most likely it's a bug. I don't like if buggy program state continues to silently persist and be interpreted somehow. Even if you consider that null collection is not a bug, nobody says that null collection is the same as empty collection. If it's true for your program, it could be not true to my program. And if it's true in your program, why you have two different states to describe the same situation? In general you should not have two distinct states in the program (null and empty collection) to describe the same situation. If you have them, then your program is likely to be poorly designed. I don't like to support poorly designed programs. Also note that my policy is aligned to JDK policy (e.g. |
No description provided.