-
Notifications
You must be signed in to change notification settings - Fork 211
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
Language level updated to java 8 #102
Conversation
Codecov Report
@@ Coverage Diff @@
## master #102 +/- ##
============================================
+ Coverage 75.88% 82.14% +6.25%
+ Complexity 824 808 -16
============================================
Files 72 71 -1
Lines 2322 2055 -267
Branches 312 268 -44
============================================
- Hits 1762 1688 -74
+ Misses 472 283 -189
+ Partials 88 84 -4
Continue to review full report at Codecov.
|
Yeah I think Java 8 support is fine. We were staying with Java 6 support for Android use but I think Java 8 is usable on Android now. |
import rx.Observable; | ||
import rx.functions.Func1; | ||
import rx.functions.Func2; | ||
|
||
import java.util.*; |
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.
no wildcard imports please
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.
Sorry, I used default setting of my ide. Do you have some style guide?
For a quick solution I increased the "class count to use import with '*'" to 10 in intelliJ
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.
no style guide, you can infer stuff like that from the code in front of you though.
import com.github.davidmoten.rtree.geometry.Line; | ||
import com.github.davidmoten.rtree.geometry.Point; | ||
import com.github.davidmoten.rtree.geometry.Rectangle; | ||
import com.github.davidmoten.rtree.geometry.*; |
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.
no wildcard imports please
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.
Thank for the contribution. Would be helpful if you stick to your stated aim rather than do lots of random whitespace changes (javadoc changes were a time wasting distraction to review). You could have left a lot of the code unchanged by simply changing a static import of guavamini Optional.of
to java.util.Optional.of
(again about not making me review stuff that I didn't need to). Thanks for adding the curly braces, I'm happy with those and nice to git rid of those non-lambda anonymous classes.
* | ||
* @param entry | ||
* item to add to the R-tree. | ||
* |
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.
please don't reformat javadoc, it's got nothing to do with your PR
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.
OK. In case of the static methods named "of" personally I prefer fully name, but in this case only Optional.of is used.
I will also check javadoc against master.
import java.util.Collections; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.*; |
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.
no wildcard imports please
@@ -9,30 +9,15 @@ private Functions() { | |||
} | |||
|
|||
public static <T> Func1<T, T> identity() { |
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.
Now that you've drawn my attention to them, these methods should return singletons. I prefer holder pattern if you can be bothered to change them.
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.
I agree, but for generic I cannot create static generic field like private static final Func1<T, T> IDENTITY = t -> t
Did you think something like this?
Please check solution of jdk: java.util.function.Function.identity()
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.
Would be interesting to benchmark. I would expect that this would involve less allocation cost:
// actually use a holder pattern here
private static final Func1<Object, Object> IDENTITY = t -> t;
@SuppressWarnings("unchecked")
public static final <T> Func1<T,T> identity() {
return (Func1<T, T>) IDENTITY;
}
At runtime no mucking around with generic types occurs so the cast would be to its already declared type which should be a no-op. Of course benchmarks are the real decider here.
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.
BTW we don't need a benchmark of this fact added to this project. You can add it temporarily for your own tests but don't commit. (if you are going to benchmark of course).
import java.util.Collections; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import java.util.*; |
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.
No wildcard imports
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.*; |
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.
No wildcard imports
return absent(); | ||
else | ||
return of(root.get().geometry().mbr()); | ||
return root.map(r -> r.geometry().mbr()); |
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.
As I remember you had a comment about this lambda which is disappeared somehow. Actually it can be constant if you worry about instantiating the lambda expression, but I think Optional.map is designed for this.
I have to apologize for letting this slip, you did some useful work. I'm upgrading dependencies and plugins right now. A rebased PR would be nice in a couple of days if you are willing, ta. |
# Conflicts: # pom.xml
No problem. I've just rebased the branch and checked that it still compiles. Tomorrow I will have more time to check the details and the comments. I don't remember too much. |
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.
I can see some left over changes not done yet like unrolling imports and minor naming. I'll approve and merge and fix myself, thanks!
@@ -56,10 +56,14 @@ | |||
* Current size in Entries of the RTree. | |||
*/ | |||
private final int size; | |||
private final Func2<Optional<Rectangle>, Entry<T, S>, Optional<Rectangle>> rectangleAccumulator = |
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.
should be static and called RECTANGLE_ACCUMULATOR
resolved in rtree 0.9 on Maven Central now |
Language level updated to 8
using java.util.Optional, java.util.Objects instead of guava-mini