@Override
public Table read() {
int primaryKeyCount = 0;
boolean noArgsConstructor = false;
Table table = new Table(entity.getSimpleName().toString(), entity.toString());
Map<String, AtomicInteger> countedToManyAssociations = new HashMap<String, AtomicInteger>();
for (Element child : entity.getEnclosedElements()) {
if (child.accept(new EmptyContructorVisitor(), null) != null) {
noArgsConstructor = true;
}
VariableElement column = child.accept(new ColumnElementResolvingTypeVisitor(), null);
if (column != null) {
if (hasAmbiguosAssociationDeclaration(column)) {
return null;
}
if (column.getAnnotation(PrimaryKey.class) != null && ++primaryKeyCount > 1) {
messager.printMessage(Kind.ERROR, "Only one @PrimaryKey is allowed within an @Entity", entity);
return null;
}
ColumnReader columnReader = new ColumnReader(column, messager);
Column read = columnReader.read();
if (read != null) {
table.addColumn(read);
}
}
VariableElement association = child.accept(new AssociationElementResolvingTypeVisitor(), null);
if (association != null) {
AssociationReader associationReader = new AssociationReader(association, entityNames, messager);
Association read = associationReader.read();
if (read != null) {
table.addAssociation(read);
if (AssociationType.TO_MANY == read.getCardinality()) {
if (countedToManyAssociations.containsKey(read.getCanonicalTypeInEntity())) {
countedToManyAssociations.get(read.getCanonicalTypeInEntity()).incrementAndGet();
} else {