Skip to content

Commit

Permalink
generics from HtmlElement and ImageMapArea is removed
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanseifert committed Jan 20, 2024
1 parent 65513f1 commit 77707dc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<io.wcm.handler.link.Link> delegate) {
public ImageAreaV1Impl(ImageMapArea delegate) {
super(delegate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@
*/
public class ImageAreaV2Impl implements ImageArea {

private final ImageMapArea<io.wcm.handler.link.Link> delegate;
private final ImageMapArea delegate;
private final LinkWrapper link;

/**
* @param delegate Delegate
*/
public ImageAreaV2Impl(ImageMapArea<io.wcm.handler.link.Link> 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);
}
Expand All @@ -55,6 +55,15 @@ public ImageAreaV2Impl(ImageMapArea<io.wcm.handler.link.Link> 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,16 @@ 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;
}
if (element instanceof Picture || element instanceof Image) {
element.setTitle(title);
}
else {
List<HtmlElement<?>> children = (List)element.getChildren();
for (HtmlElement<?> child : children) {
List<HtmlElement> children = (List)element.getChildren();
for (HtmlElement child : children) {
setImageTitle(child, title);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static List<ImageArea> 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<Link>(shape, coordinates, relativeCoordinates,
return new ImageAreaV1Impl(new ImageMapAreaImpl(shape, coordinates, relativeCoordinates,
link, linkUrl, linkWindowTarget, altText));
}

Expand Down

0 comments on commit 77707dc

Please sign in to comment.