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

#881 equals and hashCode for CollectionEnvelope #894

Merged
merged 5 commits into from
Jun 4, 2018
Merged

Conversation

Vatavuk
Copy link
Contributor

@Vatavuk Vatavuk commented May 20, 2018

Introduced equals and hashCode in CollectionEnvelope for #881

@0crat 0crat added the scope label May 20, 2018
@0crat
Copy link
Collaborator

0crat commented May 20, 2018

Job #894 is now in scope, role is REV

@codecov-io
Copy link

codecov-io commented May 20, 2018

Codecov Report

Merging #894 into master will increase coverage by 1.09%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #894      +/-   ##
============================================
+ Coverage     86.06%   87.15%   +1.09%     
- Complexity     1435     1467      +32     
============================================
  Files           258      259       +1     
  Lines          3767     3791      +24     
  Branches        213      213              
============================================
+ Hits           3242     3304      +62     
+ Misses          475      439      -36     
+ Partials         50       48       -2
Impacted Files Coverage Δ Complexity Δ
src/main/java/org/cactoos/list/ListEnvelope.java 100% <ø> (+6.25%) 12 <0> (-1) ⬇️
...ava/org/cactoos/collection/CollectionEnvelope.java 100% <100%> (ø) 27 <12> (+12) ⬆️
src/main/java/org/cactoos/text/SubText.java 90% <0%> (-1.31%) 8% <0%> (ø)
src/main/java/org/cactoos/scalar/LowestOf.java 100% <0%> (ø) 7% <0%> (ø) ⬇️
src/main/java/org/cactoos/scalar/NumberOf.java 94.11% <0%> (ø) 10% <0%> (ø) ⬇️
.../main/java/org/cactoos/io/LoggingOutputStream.java 89.36% <0%> (ø) 8% <0%> (ø) ⬇️
src/main/java/org/cactoos/scalar/AndInThreads.java 85.41% <0%> (ø) 18% <0%> (ø) ⬇️
src/main/java/org/cactoos/scalar/MinOf.java 79.5% <0%> (ø) 55% <0%> (ø) ⬇️
src/main/java/org/cactoos/scalar/Reduced.java 100% <0%> (ø) 5% <0%> (ø) ⬇️
src/main/java/org/cactoos/scalar/RetryScalar.java 72.72% <0%> (ø) 4% <0%> (ø) ⬇️
... and 35 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 62e1fa4...7d5974a. Read the comment docs.

other.getClass(), Collection.class
).value() > -1,
() -> new InheritanceLevel(
other.getClass(), CollectionEnvelope.class
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vatavuk I believe this isn't necessary because CollectionEnvelope is a Collection already

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@llorllale InheritanceLevel measures inheritance distance between base and derived class. It cannot determine wether a class is instance of Collection.
I'we removed first condition comparing (other.getClass(), Collection.class) because it always evaluates to false.

Copy link
Contributor Author

@Vatavuk Vatavuk May 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@llorllale the end result is that we will only compare classes that are related to CollectionEnvelope

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vatavuk We should be comparing Collections here, not CollectionEnvelopes.

I think I understand the problem now: InheritanceLevel does not check if a class implements an interface (maybe it shouldn't).

We're missing tests that compare CollectionEnvelope against regular JDK Collections. I believe they will fail with the current implementation. So we either need to a) add an instanceof (against our principles) or b) build a new type that checks if a class implements/extends an interface, or c) modify InheritanceLevel to take into account (b).

Please leave a puzzle for this and we'll merge.

@@ -147,4 +147,48 @@ public String toString() {
return this.col.value().toString();
}

@Override
public final boolean equals(final Object other) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Vatavuk this equals is missing the null-check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@llorllale fixed in d4538f8

@llorllale
Copy link
Contributor

@Vatavuk left you a couple of comments, see above.

Great PR.

@Vatavuk
Copy link
Contributor Author

Vatavuk commented May 29, 2018

@llorllale fixed and added a comment regarding InheritanceLevel

@Vatavuk
Copy link
Contributor Author

Vatavuk commented Jun 3, 2018

@llorllale added a puzzle

@llorllale
Copy link
Contributor

@Vatavuk there's a problem with the puzzle's format

@Vatavuk
Copy link
Contributor Author

Vatavuk commented Jun 3, 2018

@llorllale fixed

@llorllale
Copy link
Contributor

@rultor merge

@rultor
Copy link
Collaborator

rultor commented Jun 4, 2018

@rultor merge

@llorllale OK, I'll try to merge now. You can check the progress of the merge here

@rultor rultor merged commit 7d5974a into yegor256:master Jun 4, 2018
@rultor
Copy link
Collaborator

rultor commented Jun 4, 2018

@rultor merge

@llorllale Done! FYI, the full log is here (took me 15min)

@0crat 0crat removed the scope label Jun 4, 2018
@0crat
Copy link
Collaborator

0crat commented Jun 4, 2018

The job #894 is now out of scope

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.

5 participants