All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.ebean.querybean.generator.ReadModuleInfo Maven / Gradle / Ivy

package io.ebean.querybean.generator;

import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.AnnotationValue;
import javax.lang.model.element.Element;
import javax.lang.model.element.ExecutableElement;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Helper to read the current/existing prefixed entity classes.
 * 

* These are added back on partial compile. */ class ReadModuleInfo { private final ProcessingContext ctx; public ReadModuleInfo(ProcessingContext ctx) { this.ctx = ctx; } List read(Element element) { final List mirrors = element.getAnnotationMirrors(); for (AnnotationMirror mirror : mirrors) { final String name = mirror.getAnnotationType().asElement().toString(); if (Constants.MODULEINFO.equals(name)) { return readEntities(mirror); } } return null; } @SuppressWarnings("unchecked") private List readEntities(AnnotationMirror mirror) { final Map elementValues = mirror.getElementValues(); final Set> entries = elementValues.entrySet(); for (Map.Entry entry : entries) { if ("entities".equals(entry.getKey().getSimpleName().toString())) { final Object entitiesValue = entry.getValue().getValue(); if (entitiesValue != null) { try { List vals = new ArrayList<>(); List coll = (List) entitiesValue; for (AnnotationValue annotationValue : coll) { vals.add((String) annotationValue.getValue()); } return vals; } catch (Exception e) { ctx.logError(null, "Error reading ModuleInfo annotation, err " + e); return null; } } } } return null; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy