Skip to content

Instantly share code, notes, and snippets.

@gastaldi
Created May 10, 2018 18:45
Show Gist options
  • Save gastaldi/b5974e07a55df696e805c6e30d766470 to your computer and use it in GitHub Desktop.
Save gastaldi/b5974e07a55df696e805c6e30d766470 to your computer and use it in GitHub Desktop.
package io.thorntail.condition.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation which may be placed upon a CDI component to conditionally veto it if a class is not present.
*
* <p>If the class mentioned in the annotation cannot be found, this component will be fully veto'd by the CDI container.</p>
*
* <p>This annotation may be used repeatedly and with {@link RequiredClassNotPresent} to create complex conditoions</p>
*
* <p>All condition annotations will be applied with implicit <b>AND</b> semantics.</p>
*
* <pre>
* &#64;ApplicationScoped
* &#64;RequiredClassPresent("org.something.WhichIsRequired")
* public class MyComponent {
*
* }
* </pre>
*
* @author Ken Finnigan
* @author Bob McWhirter
*
* @see RequiredClassNotPresent
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
@Repeatable(RequiredClassPresent.List.class)
public @interface RequiredClassPresent {
String value();
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
@interface List {
RequiredClassPresent[] value();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment