Skip to content

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.

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