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

org.dbtools.codegen.java.JavaEnum Maven / Gradle / Ivy

There is a newer version: 11.0.0
Show newest version
/*
 * JavaEnum.java
 *
 * Created on March 19, 2007
 *
 * Copyright 2007 Jeff Campbell. All rights reserved. Unauthorized reproduction
 * is a violation of applicable law. This material contains certain
 * confidential or proprietary information and trade secrets of Jeff Campbell.
 */
package org.dbtools.codegen.java;

import java.util.Collections;
import java.util.List;

/**
 * @author Jeff
 */
@SuppressWarnings("PMD.UseStringBufferForStringAppends")
public class JavaEnum extends JavaClass {

    private List enums;

    public JavaEnum(String name, List enums) {
        super(name);
        setClassType(ClassType.ENUM);

        setEnums(enums);
    }

    public JavaEnum(String packageName, String name, List enums) {
        super(packageName, name);
        setClassType(ClassType.ENUM);

        setEnums(enums);
    }

    public List getEnums() {
        return Collections.unmodifiableList(enums);
    }

    public void setEnums(List enums) {
        if (enums == null || enums.isEmpty()) {
            throw new IllegalArgumentException("enums cannot be null or empty");
        }

        this.enums = enums;
    }

    @Override
    protected String buildPostClassHeader() {
        String enumStr = "";

        int count = 0;
        for (String enumItem : enums) {
            if (count > 0) {
                enumStr += ", ";
            }

            enumStr += enumItem;

            count++;
        }

        enumStr += ";\n";

        return enumStr;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy