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

com.mageddo.togglefirst.activation.ActivationStrategy Maven / Gradle / Ivy

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

import com.mageddo.togglefirst.FeatureKeys;
import com.mageddo.togglefirst.FeatureManager;
import com.mageddo.togglefirst.FeatureMetadata;
import com.mageddo.togglefirst.Status;

import java.util.Collection;
import java.util.Collections;
import java.util.UUID;

public interface ActivationStrategy {

	/**
	 * Unique id for the strategy
	 */
	UUID id();

	/**
	 * Name used to display on gui
	 */
	default String name(){
		return getClass().getSimpleName();
	}

	/**
	 * Description used to display on gui
	 */
	String description();

	default boolean isActive(FeatureMetadata featureMetadata){
		return isActive(featureMetadata, null);
	}

	boolean isActive(FeatureMetadata featureMetadata, String user);

	/**
	 * Called when {@link #isActive(FeatureMetadata, String)} returns true
	 * 
* Update feature metadata */ default void postHandleActive(FeatureManager featureManager, FeatureMetadata metadata){ metadata.set(FeatureKeys.STATUS, String.valueOf(Status.ACTIVE.getCode())); featureManager.updateMetadata(metadata.feature(), metadata.parameters()); } /** * Parameters used by the strategy to make the necessary calculation * @return */ default Collection parameters(){ return Collections.emptyList(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy