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

com.mageddo.togglefirst.EnumFeatureMetadataProvider Maven / Gradle / Ivy

There is a newer version: 1.4.9
Show newest version
package com.mageddo.togglefirst;

import com.mageddo.commons.AnnotationUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * Activating this Metadata provider you will be able to annotate your enum feature with default values and default status
 *
 * @see FeatureManager
 */
public class EnumFeatureMetadataProvider implements FeatureMetadataProvider {
	@Override
	public FeatureMetadata getMetadata(Feature feature) {
		final FeatureDefaults an = AnnotationUtils.getAnnotation(feature, FeatureDefaults.class);
		final Map m = new HashMap<>();
		if(an == null){
			m.put(FeatureKeys.STATUS, String.valueOf(Status.INACTIVE.getCode()));
			m.put(FeatureKeys.VALUE, "");
		} else {
			m.put(FeatureKeys.STATUS, String.valueOf(an.status().getCode()));
			m.put(FeatureKeys.VALUE, an.value());
		}
		return new DefaultFeatureMetadata(feature, m);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy