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

Moved deprecated Value.get* methods to single-valued types. #2557

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

danieldietrich
Copy link
Member

@danieldietrich danieldietrich commented Jan 17, 2020

Fixes #2450

This is a DRAFT pull request for deprecating the Value methods and moving them to the right locations. The main ideas are described in the blog post Purifying the API surface area.

Renaming things isn't a good idea regarding backward compatibility, however, moving some APIs to the right place is essential for the health of the Vavr library. Here are the main changes I did in this PR:

Removed from Value and sub-classes (without replacement):

  • isAsync()
  • isSingleValued()
  • out(PrintStream), out(PrintWriter)
  • stdout(), stderr()
  • eq(Object), corresponds(Iterable, BiPredicate) --> Java has its own notion for equality. introducing a new notion, especially across a complex type hierarchy, is questionable
  • forEach --> contained in super-interface java.lang.Iterable

Moved from Value to Traversable:

  • isLazy()
  • map(Function)
  • peek(Consumer)
  • stringPrefix()
  • contains(Object)
  • exists(Predicate)
  • forAll(Predicate)
  • forEach(Consumer)
  • collect
  • to*(...) conversion functions

Moved from Value to Option, Try, Either, Validation, Future:

  • isEmpty
  • map(Function) -->
  • selected to*(...) conversion functions
  • spliterator()

Moved Foldable.* to Traversable and removed Foldable interface:

  • Note: its only purpose was to internally structure the code

Removed from collections:

  • get*(...) --> they belong to Option, Either, Try, Validation and Future
  • reject(predicate) --> use filterNot(predicate) or filter(predicate.negate())
  • removeAll(predicate) --> use filter(predicate)

Removed from Either (without replacement):

  • left() and Either.LeftProjection --> use swap()
  • right() and Either.RightProjection --> Either is right biased

Removed from Future (without replacement):

  • DEFAULT_EXECUTOR_SERVICE --> use DEFAULT_EXECUTOR instead
  • ofSupplier(...), ofCallable(...), ofRunnable(...) --> use of(...) instead

Removed from Promise (without replacement):

  • executorService() --> use the executor() instead

Removed HashCodes interface (without replacement)

Removed from PartialFunction (without replacement):

  • removed lift(), unlift() and getIfDefined()

@codecov-io
Copy link

codecov-io commented Jan 17, 2020

Codecov Report

Merging #2557 into master will increase coverage by 0.21%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2557      +/-   ##
============================================
+ Coverage      92.8%   93.02%   +0.21%     
- Complexity     5300     5551     +251     
============================================
  Files            89       89              
  Lines         12706    13101     +395     
  Branches       1609     1660      +51     
============================================
+ Hits          11792    12187     +395     
  Misses          727      727              
  Partials        187      187
Impacted Files Coverage Δ Complexity Δ
src/main/java/io/vavr/collection/Traversable.java 96.56% <ø> (ø) 106 <0> (ø) ⬇️
src/main/java/io/vavr/Value.java 93.83% <ø> (ø) 145 <0> (ø) ⬇️
src/main/java/io/vavr/Lazy.java 100% <ø> (ø) 35 <0> (ø) ⬇️
src/main/java/io/vavr/control/Option.java 92.77% <ø> (ø) 46 <0> (ø) ⬇️
src/main/java/io/vavr/control/Try.java 96.54% <100%> (+0.07%) 109 <6> (+6) ⬆️
src/main/java/io/vavr/concurrent/Future.java 97.72% <100%> (+0.07%) 133 <6> (+6) ⬆️
src/main/java/io/vavr/control/Validation.java 96.49% <100%> (+0.11%) 65 <6> (+6) ⬆️
src/main/java/io/vavr/control/Either.java 97.42% <100%> (+0.07%) 65 <6> (+6) ⬆️
src-gen/main/java/io/vavr/Tuple2.java 89% <0%> (+6.18%) 53% <0%> (+22%) ⬆️
src-gen/main/java/io/vavr/Tuple1.java 85.91% <0%> (+8.13%) 37% <0%> (+16%) ⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2a4b7c4...d773a9a. Read the comment docs.

@danieldietrich danieldietrich changed the title Deprecating methods of Value Moved deprecated Value.get* methods to single-valued types. Jan 20, 2020
@codecov-commenter
Copy link

Codecov Report

Merging #2557 into master will increase coverage by 0.18%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2557      +/-   ##
============================================
+ Coverage     92.84%   93.02%   +0.18%     
- Complexity     5347     5551     +204     
============================================
  Files            89       89              
  Lines         12740    13101     +361     
  Branches       1608     1660      +52     
============================================
+ Hits          11828    12187     +359     
- Misses          723      727       +4     
+ Partials        189      187       -2     
Impacted Files Coverage Δ Complexity Δ
src/main/java/io/vavr/Lazy.java 100.00% <ø> (ø) 35.00 <0.00> (ø)
src/main/java/io/vavr/Value.java 93.83% <ø> (ø) 145.00 <0.00> (ø)
src/main/java/io/vavr/collection/Traversable.java 96.56% <ø> (ø) 106.00 <0.00> (ø)
src/main/java/io/vavr/control/Option.java 92.77% <ø> (+1.10%) 46.00 <0.00> (-2.00) ⬆️
src/main/java/io/vavr/concurrent/Future.java 97.72% <100.00%> (+0.07%) 133.00 <6.00> (+6.00)
src/main/java/io/vavr/control/Either.java 97.42% <100.00%> (+0.07%) 65.00 <6.00> (+6.00)
src/main/java/io/vavr/control/Try.java 96.54% <100.00%> (+0.07%) 109.00 <6.00> (+6.00)
src/main/java/io/vavr/control/Validation.java 96.49% <100.00%> (+0.11%) 65.00 <6.00> (+6.00)
src/main/java/io/vavr/collection/Seq.java 90.00% <0.00%> (-6.16%) 40.00% <0.00%> (-6.00%)
src/main/java/io/vavr/collection/Map.java 94.44% <0.00%> (-3.64%) 33.00% <0.00%> (ø%)
... and 37 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bc3c652...a752345. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate methods of Value
3 participants