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

Adjust reverse and reverseInternal visibility and type narrowing #582

Merged
merged 2 commits into from
Aug 26, 2020

Conversation

jodygarnett
Copy link
Contributor

@jodygarnett jodygarnett commented Aug 18, 2020

This change addresses an unintended consequence where the visibility of these methods as implemented by geometry subclasses was consistent.

  • consistent public visibility for reverse() methods
  • consistent protected visibility for reverseInternal() methods
  • type narrowing for each subclass implementation of reverse()
  • subclass implementations of reverse() are not deprecated

Signed-off-by: Jody Garnett jody.garnett@gmail.com

This change addresses an unintended consequence where the visibility of these methods as implemented by geometry subclasses was inconsistent.

Signed-off-by: Jody Garnett <jody.garnett@gmail.com>
@@ -132,13 +132,12 @@ protected LinearRing copyInternal() {
return new LinearRing(points.copy(), factory);
}

/** @deprecated */
public Geometry reverse()
public LinearRing reverse()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is no longer deprecated, a change that was producing warnings in client code.

*/
public Geometry reverse() {
return super.reverse();
public MultiLineString reverse() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is no longer deprecated, which was producing warnings in client code.

@jodygarnett
Copy link
Contributor Author

Discussion with @jnh5y asks about the use of @Override annotation. These methods are appropriate for the @Override annotation, but I did not see it used elsewhere in the Geometry implementation ...

Happy to add @Override, especially to the protected reverseInternal() method which would be easy to miss during a refactoring.

@dr-jts
Copy link
Contributor

dr-jts commented Aug 21, 2020

Is the type-narrowing needed? Or just the removal of deprecated?

@dr-jts
Copy link
Contributor

dr-jts commented Aug 21, 2020

Is it even necessary to have reverse() methods on subclasses, given that they all delegate to the Geometry method?

@jodygarnett
Copy link
Contributor Author

Is it even necessary to have reverse() methods on subclasses, given that they all delegate to the Geometry method?

The one advantage is the type narrowing, in case where the geometry type is known.

@jodygarnett
Copy link
Contributor Author

Is the type-narrowing needed? Or just the removal of deprecated?

I decided to be explicit and check each case, the removal and deprecated and the change of method visibility are the priority.

@jnh5y
Copy link
Contributor

jnh5y commented Aug 26, 2020

Alright, finally had a second to look into this more.

Jody's type narrowing is the same as how copyInternal is currently handled on master. Given that precedent, I think the type narrowing is justified.

}

public Geometry reverseInternal() {
public LinearRing reverseInternal() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this should be protected; otherwise this will be the only reverseInternal which has public scope!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, good catch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry I missed applying this feedback :(

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, I think you switched reverse to protected instead of this method.

Signed-off-by: Jody Garnett <jody.garnett@gmail.com>
@jodygarnett jodygarnett merged commit aa8a6a4 into locationtech:master Aug 26, 2020
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.

3 participants