-
Notifications
You must be signed in to change notification settings - Fork 170
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
(#1184) CollectionEnvelope is just an envelope #1216
Conversation
Job #1216 is now in scope, role is |
Codecov Report
@@ Coverage Diff @@
## master #1216 +/- ##
============================================
- Coverage 89.36% 89.32% -0.05%
- Complexity 1683 1686 +3
============================================
Files 280 280
Lines 4034 4028 -6
Branches 213 212 -1
============================================
- Hits 3605 3598 -7
- Misses 394 396 +2
+ Partials 35 34 -1
Continue to review full report at Codecov.
|
This pull request #1216 is assigned to @fabriciofx/z, here is why; the budget is 15 minutes, see §4; please, read §27 and when you decide to accept the changes, inform @paulodamaso/z (the architect) right in this ticket; if you decide that this PR should not be accepted ever, also inform the architect; this blog post will help you understand what is expected from a code reviewer; there will be no monetary reward for this job |
@victornoel I liked your idea, but I'm not too sure about just removing |
@paulodamaso yes, I think you are right! also is there any way to remove @fabriciofx from the project? It is making us wait a lot of time everytime he is assigned... |
@paulodamaso , that's very true. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel please, take a look.
iterator.next(); | ||
iterator.remove(); | ||
new Assertion<>( | ||
"Iterator should be empty", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel please, change "Iterator should be empty"
to "Must be Iterator empty"
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabriciofx IMHO, in this case it does not sound properly in English. The correct form is:"Iterator must be empty" or "Must be empty"(if iterator is meant).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fanifieiev is "Must be an empty Iterator" better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabriciofx Well, yes, it is better, but still the meaning is not as MUST if you want to express obligation, but rather is a certainty.
You can have a look at the way 'must' is used at https://www.grammar.cl/english/must.htm or at https://www.crownacademyenglish.com/modal-verb-must-form-use-meaning/
So, what you suggest is called "Deductions and conclusions"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fanifieiev so, what's your recommendation? Please, note (almost) all fail test messages in Cactoos starts with Must...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabriciofx "
As an alternative, "Must return an empty Iterator" is also good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fanifieiev I liked "Must return an empty Iterator". Thanks a lot @fanifieiev!!! ✌️ 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabriciofx You are welcome!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabriciofx @fanifieiev thx, I've applied this for all the other below too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel ok
final Collection<String> envelope = new CollectionOf<>(); | ||
final Collection<String> collection = Collections.emptyList(); | ||
new Assertion<>( | ||
"Empty envelope and collection should be equal", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel same above (with properly adaptation).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabriciofx actually I removed this one because the test is redundant with one of the above and it has nothing to do with envelope anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel ok
final Collection<String> collection = new ArrayList<>(1); | ||
collection.add("a"); | ||
new Assertion<>( | ||
"Envelope and collection should be equal", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel same above (with properly adaptation).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabriciofx actually I removed this one because the test is redundant with one of the above and it has nothing to do with envelope anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel ok
801c5cd
to
5172e56
Compare
@fabriciofx sorry for the delay, see the changes I made |
@victornoel please, fix first the problem with CIs. |
5172e56
to
789899a
Compare
@fabriciofx it is fixed, thx for the heads up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel please, take a look again.
*/ | ||
public Mapped(final Func<X, Y> fnc, final Collection<X> src) { | ||
super(() -> new CollectionOf<>( | ||
super(new Sticky<>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel please, use the same indentation here which you used bellow (IMHO it's better).
} | ||
|
||
/** | ||
* Ctor. | ||
* @param list Items to concatenate | ||
*/ | ||
public Joined(final Iterable<Iterable<X>> list) { | ||
super(() -> new CollectionOf<X>( | ||
super(new Sticky<>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel please, use the same indentation here which you used bellow (IMHO it's better).
*/ | ||
public HeadOf(final int num, final Collection<T> src) { | ||
super(() -> new CollectionOf<T>( | ||
super(new Sticky<T>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel please, use the same indentation here which you used bellow (IMHO it's better).
@@ -53,7 +53,7 @@ public Filtered(final Func<X, Boolean> func, final X... src) { | |||
* @param src Source collection | |||
*/ | |||
public Filtered(final Func<X, Boolean> func, final Iterable<X> src) { | |||
super(() -> new CollectionOf<>( | |||
super(new Sticky<>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel please, use the same indentation here which you used bellow (IMHO it's better).
@@ -60,13 +72,131 @@ public CollectionOf(final T... array) { | |||
* @param src An {@link Iterable} | |||
*/ | |||
public CollectionOf(final Iterable<T> src) { | |||
super(() -> { | |||
this(() -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel please, use the same indentation here which you used bellow (IMHO it's better).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabriciofx I don't think it is going to look better for a lambda like this...
// @checkstyle MagicNumberCheck (30 lines) | ||
@Override | ||
public int hashCode() { | ||
return new Unchecked<>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel please, use HashCode
instead.
*/ | ||
public Skipped(final int skip, final Collection<T> src) { | ||
super(() -> new CollectionOf<>( | ||
super(new Sticky<>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel please, use the same indentation here which you used bellow (IMHO it's better).
super(() -> new CollectionOf<T>( | ||
new org.cactoos.iterable.Sliced<T>(start, count, collection) | ||
public Sliced(final int start, final int count, final Iterable<T> src) { | ||
super(new Sticky<>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel please, use the same indentation here which you used bellow (IMHO it's better).
*/ | ||
public TailOf(final int num, final Collection<T> src) { | ||
super(() -> new CollectionOf<T>( | ||
super(new Sticky<T>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel please, use the same indentation here which you used bellow (IMHO it's better).
789899a
to
4a54e9a
Compare
@fabriciofx it's done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel please, take look one more time.
|
||
@Override | ||
public int hashCode() { | ||
return new HashCode(this).value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel I don't think it the correct way to use HashCode
. You must pass the attributes to the constructor, right? WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fabriciofx I've modified HashCode
so that it can take an Iterable
of attributes, so this
is an Iterable
of the elements of the collection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@victornoel sounds good to me
@victornoel it seems fine to me. @paulodamaso can you merge it? |
@victornoel Therew are conflicts, please take a look |
4a54e9a
to
95f5a04
Compare
@paulodamaso thank you, it should be fixed |
@rultor merge |
@paulodamaso OK, I'll try to merge now. You can check the progress of the merge here |
@paulodamaso Done! FYI, the full log is here (took me 12min) |
@sereshqua/z please review this job completed by @fabriciofx/z, as in §30; the job will be fully closed and all payments will be made when the quality review is completed |
Code review was too long (16 days), architects (@paulodamaso) were penalized, see §55 |
The job #1216 is now out of scope |
Payment to |
@0crat quality good |
Order was finished, quality is "good": +20 point(s) just awarded to @fabriciofx/z |
Quality review completed: +4 point(s) just awarded to @sereshqua/z |
This is for #1184
I had to work around all the strange behaviours that crept in the collection package for some time. There were many incoherence between javadoc, behaviour, different implementations of
Collection
, etc.This is what I did:
IterableEnvelope
, I moved out of the envelope everything that does not pertain to it and put it inCollectionOf
so that it retains its behaviour.Sticky
because the previous behaviour of the envelope was to be sticky (if I don't, tests forJoined
andReversed
stop working, because they were written so that those implementation were sticky and mutable).Collection
in most classes sinceCollection
is anIterable
already, this should remove some extra overhead at runtime and simplify understanding of the code@todo
to continue making things more coherent in this packageHonestly the collection package and
CollectionOf
in particular is very awkward because aCollection
is anIterable
, it is not "based on anIterable
" likeIterable
is "based onIterator
" but the javadoc and the whole abstraction seems to be designed as if it was the case. I almost wonder if we shouldn't just deleteCollectionOf
and leaveList
orSet
be responsible of instantiating new collections. Even the decorators are strange to me. @paulodamaso WDYT?