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

com.github.loicoudot.java4cpp.EnumAnalyzer Maven / Gradle / Ivy

package com.github.loicoudot.java4cpp;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

import com.github.loicoudot.java4cpp.model.ClassModel;

public class EnumAnalyzer extends Analyzer {

    public EnumAnalyzer(Context context) {
        super(context);
    }

    @Override
    public void fill(ClassModel classModel) {
        for (String key : getEnumKeys(classModel.getType().getClazz())) {
            classModel.getContent().addEnumKey(key);
        }
    }

    private List getEnumKeys(Class clazz) {
        List enumKeys = new ArrayList();
        for (Field field : clazz.getFields()) {
            if (field.isEnumConstant()) {
                enumKeys.add(mappings.escapeName(field.getName()));
            }
        }
        return enumKeys;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy