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

Remove method from interface ILayer and update all places accordingly #619

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

Conversation

sschulz92
Copy link
Contributor

Within this PR I removed isType() from interface ILayer.java which is deprecated. I updated all remaining places accordingly :)

"New" way to go: hasResource()

@fgdrf
Copy link
Contributor

fgdrf commented Nov 25, 2021

I had a look at the Implementations of ILayer and isType and hasResource were not implemented the same way:

WMSLaser:

public <T> boolean isType(Class<T> resourceType) {
if (resourceType == Layer.class) {
return true;
}
return false;
}

@Override
public <T> boolean hasResource(Class<T> resourceType) {
return false;
}

whereas layerImpl is fine in my option:

/**
* @deprecated
*/
@Deprecated
@Override
public <T> boolean isType(Class<T> resourceType) {
return hasResource(resourceType);
}
@Override
public <T> boolean hasResource(Class<T> resourceType) {
for (IGeoResource resource : getGeoResources()) {
if (resource.canResolve(resourceType))
return true;
}
return false;
}

and LayerDecorator just delegates to the wrapped Layer which is fine to.

So I guess we at least WMSLayer should be adapted and I'd prefer to add a hint to release-notes for 2.3 as well (https://github.com/locationtech/udig-platform/blob/dca5ae79fdf5f90f343e80ef10c627e03b7cb076/docs/user/en/what_is_new/What%20is%20new%202.3.rst)

@fgdrf fgdrf self-requested a review November 25, 2021 08:05
Copy link
Contributor

@fgdrf fgdrf left a comment

Choose a reason for hiding this comment

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

as stated in previous comment, at least WMSLayer might raise some issues because implementations of isType and hasResource aret different.

@@ -91,9 +91,9 @@ static void writeContext(IMap map, BufferedWriter out) throws IOException {
append(2, out, "<ResourceList>"); //$NON-NLS-1$
for (ILayer layer : map.getMapLayers()) {
try {
if (layer.isType(Layer.class)) {
if (layer.hasResource(Layer.class)) {
writeLayer(layer, out);
Copy link
Contributor

Choose a reason for hiding this comment

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

wondering what would happen here, since WMSLayer.hasResource() is always false whereas isType was true ..

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically WMSLayer.java is located into the module "org.locationtech.udig.info.tests" - so it's a test class. Does it really that matter? From my perspective we may even think about removing this class (should not belong to a test bundle).

@sschulz92 sschulz92 requested a review from fgdrf November 26, 2021 07:23
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.

2 participants