-
Notifications
You must be signed in to change notification settings - Fork 5
/
Switcher.java
34 lines (26 loc) · 1.05 KB
/
Switcher.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
package org.genericsystem.reactor.annotations;
import java.lang.annotation.Annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.util.function.BiConsumer;
import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.annotations.Switcher.SwicherProcessor;
import org.genericsystem.reactor.gscomponents.Controller;
import org.genericsystem.reactor.gscomponents.TagImpl;
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
@Process(SwicherProcessor.class)
public @interface Switcher {
public static final String CONTROLLER = "controller";
Class<? extends TagImpl> value();
Class<? extends TagImpl>[] path() default {};
int[] pos() default {};
public static class SwicherProcessor implements BiConsumer<Annotation, Tag> {
@Override
public void accept(Annotation annotation, Tag tag) {
tag.createNewInitializedProperty(CONTROLLER, context -> new Controller(((Switcher) annotation).value()));
}
}
}