diff --git a/core/src/main/java/io/wcm/testing/mock/aem/dam/MockAsset.java b/core/src/main/java/io/wcm/testing/mock/aem/dam/MockAsset.java index 7b0316bd..010583bf 100644 --- a/core/src/main/java/io/wcm/testing/mock/aem/dam/MockAsset.java +++ b/core/src/main/java/io/wcm/testing/mock/aem/dam/MockAsset.java @@ -76,15 +76,14 @@ class MockAsset extends ResourceWrapper implements Asset { this.bundleContext = bundleContext; } - @SuppressWarnings("unchecked") @Override public AdapterType adaptTo(Class 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); } diff --git a/core/src/main/java/io/wcm/testing/mock/aem/dam/MockGraniteAssetWrapper.java b/core/src/main/java/io/wcm/testing/mock/aem/dam/MockGraniteAssetWrapper.java index 38da61cc..939d69c7 100644 --- a/core/src/main/java/io/wcm/testing/mock/aem/dam/MockGraniteAssetWrapper.java +++ b/core/src/main/java/io/wcm/testing/mock/aem/dam/MockGraniteAssetWrapper.java @@ -49,12 +49,11 @@ public class MockGraniteAssetWrapper extends ResourceWrapper implements Asset { this.asset = asset; } - @SuppressWarnings("unchecked") @Override public AdapterType adaptTo(Class 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); }