-
Notifications
You must be signed in to change notification settings - Fork 4
/
SpeciesProcessor.java
45 lines (38 loc) · 1.58 KB
/
SpeciesProcessor.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
/*******************************************************************************************************
*
* SpeciesProcessor.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 javax.lang.model.element.Element;
import javax.lang.model.element.TypeElement;
import msi.gama.precompiler.GamlAnnotations.species;
/**
* The Class SpeciesProcessor.
*/
public class SpeciesProcessor extends ElementProcessor<species> {
@Override
protected Class<species> getAnnotationClass() {
return species.class;
}
@Override
public void createElement(final StringBuilder sb, final ProcessorContext context, final Element e,
final species spec) {
final String clazz = rawNameOf(context, e.asType());
verifyDoc(context, e, "species " + spec.name(), spec);
sb.append(in).append("_species(").append(toJavaString(spec.name())).append(",").append(toClassObject(clazz))
.append(",(p, i)->").append("new ").append(clazz).append("(p, i),");
toArrayOfStrings(spec.skills(), sb).append(");");
}
@Override
protected boolean validateElement(final ProcessorContext context, final Element e) {
boolean result =
assertClassExtends(context, true, (TypeElement) e, context.getType("msi.gama.metamodel.agent.IAgent"));
return result;
}
}