From 77707dca396ec0c9ef896081f6ec29d4aa0a3357 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Sat, 20 Jan 2024 10:57:12 +0100 Subject: [PATCH] generics from HtmlElement and ImageMapArea is removed --- .../impl/models/helpers/ImageAreaV1Impl.java | 4 ++-- .../impl/models/helpers/ImageAreaV2Impl.java | 15 ++++++++++++--- .../models/wcmio/v1/ResponsiveImageV1Impl.java | 6 +++--- .../components/testcontext/ImageAreaTestData.java | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV1Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV1Impl.java index 6278eeef..6bb0364f 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV1Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV1Impl.java @@ -33,12 +33,12 @@ /** * Implementation of {@link ImageArea}. */ -public class ImageAreaV1Impl extends ImageAreaV2Impl { +public final class ImageAreaV1Impl extends ImageAreaV2Impl { /** * @param delegate Delegate */ - public ImageAreaV1Impl(ImageMapArea delegate) { + public ImageAreaV1Impl(ImageMapArea delegate) { super(delegate); } diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV2Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV2Impl.java index 3e4beba6..e263e353 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV2Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/helpers/ImageAreaV2Impl.java @@ -38,15 +38,15 @@ */ public class ImageAreaV2Impl implements ImageArea { - private final ImageMapArea delegate; + private final ImageMapArea delegate; private final LinkWrapper link; /** * @param delegate Delegate */ - public ImageAreaV2Impl(ImageMapArea delegate) { + public ImageAreaV2Impl(ImageMapArea delegate) { this.delegate = delegate; - io.wcm.handler.link.Link delegateLink = delegate.getLink(); + io.wcm.handler.link.Link delegateLink = toLink(delegate.getLink()); if (delegateLink != null) { this.link = new LinkWrapper(delegateLink); } @@ -55,6 +55,15 @@ public ImageAreaV2Impl(ImageMapArea delegate) { } } + private io.wcm.handler.link.Link toLink(Object linkObject) { + if (linkObject instanceof io.wcm.handler.link.Link) { + return (io.wcm.handler.link.Link)linkObject; + } + else { + return null; + } + } + @Override public String getShape() { return delegate.getShape(); diff --git a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java index a56c8698..ea8b9b53 100644 --- a/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java +++ b/bundles/core/src/main/java/io/wcm/wcm/core/components/impl/models/wcmio/v1/ResponsiveImageV1Impl.java @@ -175,7 +175,7 @@ private void initPropertiesFromDamAsset(ValueMap properties) { } @SuppressWarnings("unchecked") - private static void setImageTitle(HtmlElement element, String title) { + private static void setImageTitle(HtmlElement element, String title) { if (element == null) { return; } @@ -183,8 +183,8 @@ private static void setImageTitle(HtmlElement element, String title) { element.setTitle(title); } else { - List> children = (List)element.getChildren(); - for (HtmlElement child : children) { + List children = (List)element.getChildren(); + for (HtmlElement child : children) { setImageTitle(child, title); } } diff --git a/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/ImageAreaTestData.java b/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/ImageAreaTestData.java index 2728d4e4..6e18b9c0 100644 --- a/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/ImageAreaTestData.java +++ b/bundles/core/src/test/java/io/wcm/wcm/core/components/testcontext/ImageAreaTestData.java @@ -68,7 +68,7 @@ public static List getExpectedAreasV1(AemContext context) { private static ImageArea areaV1(@NotNull String shape, @NotNull String coordinates, @Nullable String relativeCoordinates, @Nullable Link link, @NotNull String linkUrl, @Nullable String linkWindowTarget, @Nullable String altText) { - return new ImageAreaV1Impl(new ImageMapAreaImpl(shape, coordinates, relativeCoordinates, + return new ImageAreaV1Impl(new ImageMapAreaImpl(shape, coordinates, relativeCoordinates, link, linkUrl, linkWindowTarget, altText)); }