ImageMapLinkResolver.java

  1. /*
  2.  * #%L
  3.  * wcm.io
  4.  * %%
  5.  * Copyright (C) 2019 wcm.io
  6.  * %%
  7.  * Licensed under the Apache License, Version 2.0 (the "License");
  8.  * you may not use this file except in compliance with the License.
  9.  * You may obtain a copy of the License at
  10.  *
  11.  *      http://www.apache.org/licenses/LICENSE-2.0
  12.  *
  13.  * Unless required by applicable law or agreed to in writing, software
  14.  * distributed under the License is distributed on an "AS IS" BASIS,
  15.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16.  * See the License for the specific language governing permissions and
  17.  * limitations under the License.
  18.  * #L%
  19.  */
  20. package io.wcm.handler.media.spi;

  21. import org.apache.sling.api.resource.Resource;
  22. import org.jetbrains.annotations.NotNull;
  23. import org.jetbrains.annotations.Nullable;
  24. import org.osgi.annotation.versioning.ConsumerType;

  25. /**
  26.  * Resolves link URLs found in Image Map definitions.
  27.  * To be implemented by an OSGi service provided by wcm.io Link Handler.
  28.  * @param <T> Link result type
  29.  */
  30. @ConsumerType
  31. public interface ImageMapLinkResolver<T> {

  32.   /**
  33.    * Resolve link.
  34.    * @param linkUrl Link URL
  35.    * @param linkWindowTarget Link window target
  36.    * @param context Context resource where the image map is defined
  37.    * @return Resolved link object (may be invalid)
  38.    */
  39.   @Nullable
  40.   default T resolveLink(@NotNull String linkUrl, @Nullable String linkWindowTarget, @NotNull Resource context) {
  41.     return null;
  42.   }

  43.   /**
  44.    * Get Link URL from link Object.
  45.    * @param link Link object
  46.    * @return Resolved link URL or null
  47.    */
  48.   @Nullable
  49.   default String getLinkUrl(@Nullable T link) {
  50.     return null;
  51.   }

  52. }