mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-17 01:17:29 +02:00
26 lines
630 B
Java
26 lines
630 B
Java
package no.finn.unleash;
|
|
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
|
|
final class ToggleCollection {
|
|
private Collection<Toggle> features = Collections.emptyList();
|
|
private Map<String, Toggle> cache;
|
|
|
|
ToggleCollection(final Collection<Toggle> features) {
|
|
this.features = features;
|
|
cache = new HashMap<>();
|
|
features.forEach(toggle -> cache.put(toggle.getName(), toggle));
|
|
}
|
|
|
|
Collection<Toggle> getFeatures() {
|
|
return features;
|
|
}
|
|
|
|
Toggle getToggle(final String name) {
|
|
return cache.get(name);
|
|
}
|
|
}
|