-
Notifications
You must be signed in to change notification settings - Fork 4
/
IProcessor.java
99 lines (89 loc) · 2.25 KB
/
IProcessor.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*******************************************************************************************************
*
* IProcessor.java, in msi.gama.processor, is part of the source code of the
* GAMA modeling and simulation platform (v.1.8.2).
*
* (c) 2007-2022 UMI 209 UMMISCO IRD/SU & Partners (IRIT, MIAT, TLU, CTU)
*
* Visit https://github.com/gama-platform/gama for license information and contacts.
*
********************************************************************************************************/
package msi.gama.precompiler;
import java.lang.annotation.Annotation;
import java.util.Collection;
/**
* Individual processors taking care of specific annotations (class parameter). They are fed with the annotated elements
* and expected to produce java source code (if they return true to outputToJava()) that fills a method
*
* @author Alexis Drogoul
*
* @param <T>
*/
public interface IProcessor<T extends Annotation> {
/**
* Process.
*
* @param context the context
*/
default void process(final ProcessorContext context) {}
/**
* Gets the initialization method name.
*
* @return the initialization method name
*/
/*
* Returns the name of the initialization method in which the elements will be written
*
* @return a string or null if no output to Java
*/
default String getInitializationMethodName() {
return null;
}
/**
* Gets the exceptions.
*
* @return the exceptions
*/
/*
* The exceptions that should decorate the initialization method
*/
default String getExceptions() {
return "";
}
/**
* Output to java.
*
* @return true, if successful
*/
/*
* Returns whether or not this processor produces Java code
*/
default boolean outputToJava() {
return true;
}
/**
* Checks for elements.
*
* @return true, if successful
*/
/*
* Returns whether or not this processor has elements to process
*
*/
boolean hasElements();
/**
* Serialize.
*
* @param context the context
* @param elements the elements
* @param sb the sb
*/
void serialize(ProcessorContext context, Collection<StringBuilder> elements, StringBuilder sb);
/**
* Write java body.
*
* @param sb the sb
* @param context the context
*/
void writeJavaBody(StringBuilder sb, ProcessorContext context);
}