Skip to content

Commit

Permalink
Avoid unchecked warnings by using type.cast()
Browse files Browse the repository at this point in the history
  • Loading branch information
Bart Thierens committed Aug 19, 2024
1 parent cbef8f3 commit 0000000
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 2 additions & 3 deletions core/src/main/java/io/wcm/testing/mock/aem/dam/MockAsset.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,14 @@ class MockAsset extends ResourceWrapper implements Asset {
this.bundleContext = bundleContext;
}

@SuppressWarnings("unchecked")
@Override
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
if (type == Resource.class) {
return (AdapterType)resource;
return type.cast(resource);
}
//to be able to adapt to granite asset
if (type == com.adobe.granite.asset.api.Asset.class) {
return (AdapterType)new MockGraniteAssetWrapper(this);
return type.cast(new MockGraniteAssetWrapper(this));
}
return super.adaptTo(type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ public class MockGraniteAssetWrapper extends ResourceWrapper implements Asset {
this.asset = asset;
}

@SuppressWarnings("unchecked")
@Override
public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
//to be able to adapt to CQ asset
if (type == com.day.cq.dam.api.Asset.class) {
return (AdapterType)asset;
return type.cast(asset);
}
return asset.adaptTo(type);
}
Expand Down

0 comments on commit 0000000

Please sign in to comment.