All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.mule.runtime.module.extension.api.loader.java.type.WithAnnotations Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */
package org.mule.runtime.module.extension.api.loader.java.type;

import org.mule.api.annotation.NoImplement;

import java.lang.annotation.Annotation;
import java.util.Optional;

/**
 * A generic contract for any kind of component that can be annotated
 *
 * @since 4.0
 */
@NoImplement
public interface WithAnnotations {

  /**
   * Retrieves an annotation of the {@link WithAnnotations} component
   *
   * @param annotationClass Of the annotation to retrieve
   * @param              The annotation type
   * @return The {@link Optional} annotation to retrieve
   */
   Optional getAnnotation(Class annotationClass);

  /**
   * Returns an optional {@link AnnotationValueFetcher} which encapsulates the logic of obtaining annotations values
   * when executing with classes or with the Java AST.
   *
   * @param annotationClass Of the annotation to retrieve
   * @param              The annotation type
   * @return The {@link Optional} {@link AnnotationValueFetcher} to retrieve
   * @since 4.1
   */
   Optional> getValueFromAnnotation(Class annotationClass);

  /**
   * @param annotation The annotation to verify if the, {@link WithAnnotations} is annotated with.
   * @return A {@code boolean} indicating if the {@link WithAnnotations} element is annotated with the given {@code annotation}
   */
  default boolean isAnnotatedWith(Class annotation) {
    return getAnnotation(annotation).isPresent();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy