mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-20 04:31:06 +00:00
added exception in case the feature is not known to the system
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.templating.Templatable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class FeatureNotFoundException extends AbstractoRunTimeException implements Templatable {
|
||||
|
||||
private String feature;
|
||||
private List<String> availableFeatures;
|
||||
|
||||
public FeatureNotFoundException(String message, String feature, List<String> availableFeatures) {
|
||||
super(message);
|
||||
this.feature = feature;
|
||||
this.availableFeatures = availableFeatures;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "feature_not_found";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
HashMap<String, Object> parameters = new HashMap<>();
|
||||
parameters.put("featureName", this.feature);
|
||||
parameters.put("availableFeatures", this.availableFeatures);
|
||||
return parameters;
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,6 @@ package dev.sheldan.abstracto.core.service;
|
||||
|
||||
public interface FeatureFlagService {
|
||||
boolean isFeatureEnabled(String name, Long serverId);
|
||||
void enableFeature(String name, Long serverId);
|
||||
void disableFeature(String name, Long serverId);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,6 @@ public interface FeatureFlagManagementService {
|
||||
void createFeatureFlag(String key, Long serverId, Boolean newValue);
|
||||
void createFeatureFlag(String key, AServer server, Boolean newValue);
|
||||
boolean getFeatureFlagValue(String key, Long serverId);
|
||||
void updateOrCreateFeatureFlag(String key, Long serverId, Boolean newValue);
|
||||
void updateFeatureFlag(String key, Long serverId, Boolean newValue);
|
||||
Optional<AFeatureFlag> getFeatureFlag(String key, Long serverId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user