/
MarkerMappingRef.java
50 lines (43 loc) · 1.94 KB
/
MarkerMappingRef.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* Hibernate Search, full-text search for your domain model
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.search.mapper.pojo.bridge.declaration;
import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.hibernate.search.mapper.pojo.bridge.mapping.AnnotationMarkerBuilder;
import org.hibernate.search.mapper.pojo.bridge.mapping.MarkerBuilder;
/**
* Reference a marker mapping builder in a {@link MarkerMapping}.
* <p>
* Reference can be obtained using either a name or a type.
* <p>
* Each time the mapped annotation is encountered, an instance of the marker mapping builder will be created.
* The builder will be passed the annotation through its {@link AnnotationMarkerBuilder#initialize(Annotation)} method,
* and then the marker will be retrieved by calling {@link MarkerBuilder#build(org.hibernate.search.mapper.pojo.bridge.mapping.MarkerBuildContext)}.
* <p>
* Marker mapped this way can be parameterized:
* the marker mapping will be able to take any attribute of the mapped annotation into account
* in its {@link AnnotationMarkerBuilder#initialize(Annotation)} method.
*
* @author Yoann Rodiere
*/
@Documented
@Target({}) // Only used as a component in other annotations
@Retention(RetentionPolicy.RUNTIME)
public @interface MarkerMappingRef {
String builderName() default "";
Class<? extends AnnotationMarkerBuilder<?>> builderType() default UndefinedBuilderImplementationType.class;
/**
* Class used as a marker for the default value of the {@link #builderType()} attribute.
*/
abstract class UndefinedBuilderImplementationType implements AnnotationMarkerBuilder<Annotation> {
private UndefinedBuilderImplementationType() {
}
}
}