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

org.bitbucket.fermenter.stout.mda.JavaEnumeration Maven / Gradle / Ivy

package org.bitbucket.fermenter.stout.mda;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.bitbucket.fermenter.mda.metamodel.element.BaseEnumertionDecorator;
import org.bitbucket.fermenter.mda.metamodel.element.Enum;
import org.bitbucket.fermenter.mda.metamodel.element.Enumeration;

/**
 * Decorates an enumeration for easier Java rendering.
 */
public class JavaEnumeration extends BaseEnumertionDecorator implements Enumeration, JavaPackagedElement {

    private List decoratedEnums;

    /**
     * {@inheritDoc}
     */
    public JavaEnumeration(Enumeration enumerationToDecorate) {
        super(enumerationToDecorate);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List getEnums() {
        if (decoratedEnums == null) {
            List enums = wrapped.getEnums();
            if (CollectionUtils.isEmpty(enums)) {
                decoratedEnums = Collections.emptyList();

            } else {
                Enum e;
                decoratedEnums = new ArrayList<>();
                Iterator i = enums.iterator();
                while (i.hasNext()) {
                    e = i.next();
                    decoratedEnums.add(new JavaEnum(e));

                }

            }
        }

        return decoratedEnums;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy