com.fivefaces.structureclient.domain.StructureDefinition Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-structure-client Show documentation
Show all versions of common-structure-client Show documentation
structure Client for Five Faces
package com.fivefaces.structureclient.domain;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
@NoArgsConstructor
@Getter
@Setter
public class StructureDefinition {
private Class source;
private String[] requiredRoleNames = null;
private String tableName = null;
private String callName = null;
private String warehouseSchema = null;
private boolean warehouse = false;
private String insertText = null;
private boolean createUpdate = true;
private Map stringFields = new HashMap<>();
private Map integerFields = new HashMap<>();
private Map booleanFields = new HashMap<>();
private Map arrayFields = new HashMap<>();
private Map dateTimeFields = new HashMap<>();
public StructureDefinition(Class utilsClass) {
this.source = utilsClass;
Annotation[] annotations = utilsClass.getAnnotations();
for (Annotation annotation : annotations) {
if (annotation.annotationType().getName().equals(Structure.class.getCanonicalName())) {
Structure structure = (Structure) annotation;
this.requiredRoleNames = structure.roles();
this.tableName = structure.table();
this.callName = structure.callName();
this.warehouse = structure.warehouse();
this.warehouseSchema = structure.warehouseSchemaName();
this.insertText = structure.insertText();
this.createUpdate = structure.createUpdate();
}
}
for (
Field field : utilsClass.getDeclaredClasses()[0].getDeclaredFields()) {
if (field.getAnnotation(StringField.class) != null) {
this.stringFields.put(field.getName(), field.getAnnotation(StringField.class));
}
if (field.getAnnotation(IntegerField.class) != null) {
this.integerFields.put(field.getName(), field.getAnnotation(IntegerField.class));
}
if (field.getAnnotation(BooleanField.class) != null) {
this.booleanFields.put(field.getName(), field.getAnnotation(BooleanField.class));
}
if (field.getAnnotation(ArrayField.class) != null) {
this.arrayFields.put(field.getName(), field.getAnnotation(ArrayField.class));
}
if (field.getAnnotation(DateTimeField.class) != null) {
this.dateTimeFields.put(field.getName(), field.getAnnotation(DateTimeField.class));
}
}
}
}