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

com.fivefaces.structureclient.domain.StructureDefinition Maven / Gradle / Ivy

There is a newer version: 1.0.62
Show newest version
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));
            }
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy