Skip to content
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

Closed
wants to merge 27 commits into from
Closed

Improve null safety in Stream creation #155

wants to merge 27 commits into from

Conversation

landawn
Copy link

@landawn landawn commented Jul 28, 2017

No description provided.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.7%) to 97.883% when pulling 1dbc03b on landawn:master into 59d5cee on amaembo:master.

* [#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)`
@amaembo
Copy link
Owner

amaembo commented Sep 9, 2017

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. Arrays.stream do not tolerate null arrays).

@amaembo amaembo closed this Sep 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants