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

io.github.sinri.keel.mysql.dev.TableRowClassFieldLooseEnum Maven / Gradle / Ivy

Go to download

A website framework with VERT.X for ex-PHP-ers, exactly Ark Framework Users.

The newest version!
package io.github.sinri.keel.mysql.dev;

import java.util.Collection;

import static io.github.sinri.keel.helper.KeelHelpersInterface.KeelHelpers;

/**
 * @since 3.0.15
 * @since 3.0.18 Finished Technical Preview.
 */
public class TableRowClassFieldLooseEnum {
    private final String fieldName;
    private final Collection enumElements;
    private final String enumName;

    public TableRowClassFieldLooseEnum(String fieldName, Collection enumElements) {
        this.fieldName = fieldName;
        this.enumElements = enumElements;
        this.enumName = KeelHelpers.stringHelper().fromUnderScoreCaseToCamelCase(fieldName) + "Enum";
    }

    public String looseEnumName() {
        return this.enumName;
    }

    public String build() {
        StringBuilder code = new StringBuilder();
        code
                .append("\t/**\n")
                .append("\t * Enum for Field `").append(fieldName).append("` \n")
                .append("\t */\n")
                .append("\tpublic enum ").append(looseEnumName()).append(" {\n");
        enumElements.forEach(enumValue -> {
            code.append("\t\t").append(enumValue).append(",\n");
        });
        code.append("\t}\n");

        return code.toString();
    }

    @Override
    public String toString() {
        return build();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy