自定义注释以过滤实体

时间:2015-05-03 07:08:25

标签: java annotations factory

http://undancer.com/2013/10/30/Jersey-2.4-User-Guide/#ef.annotations(也是下面的代码摘录)中给出的示例中,我不太了解需要它的用例。有人可以解释一下使用这种自定义注释的原因吗?

@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@EntityFiltering
public @interface ProjectDetailedView {

    /**
     * Factory class for creating instances of {@code ProjectDetailedView} annotation.
     */
    public static class Factory
                        extends AnnotationLiteral<ProjectDetailedView>
                        implements ProjectDetailedView {

        private Factory() {
        }

        public static ProjectDetailedView get() {
            return new Factory();
        }
    }
}

0 个答案:

没有答案