com.github.blindpirate.annotationmagic.AnnotationMagician Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of annotation-magic Show documentation
Show all versions of annotation-magic Show documentation
Empower your Java annotations with magic.
package com.github.blindpirate.annotationmagic;
import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;
import java.util.stream.Stream;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
/**
* The main implementation class of {@link AnnotationMagic}. In most cases, the static
* methods in {@link AnnotationMagic} would be enough, but in case you need more fine-grained
* control over the cacheability, you can use this class.
*/
public class AnnotationMagician {
/**
* The annotation-magic-lookup is a relatively expensive operation, so we'd better
* cache the result as much as possible. In case you don't want the cached value to
* stay in memory forever, you can pass a customized cache implementation, like LRU
* cache, to the constructor.
*/
private final Map