# HG changeset patch # User Sascha L. Teichmann # Date 1343554675 0 # Node ID bd76529d612b3d6f8705ce5e3c603c45db001c90 # Parent b4ed641f01db60fe5ea06dd3039d7023776c65ff FacetActivity: Added interface and registry to decide if a facet should initially active or not. artifacts/trunk@5150 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r b4ed641f01db -r bd76529d612b ChangeLog --- a/ChangeLog Fri Jul 27 06:21:40 2012 +0000 +++ b/ChangeLog Sun Jul 29 09:37:55 2012 +0000 @@ -1,3 +1,9 @@ +2012-07-29 Sascha L. Teichmann + + * artifact-database/src/main/java/de/intevation/artifactdatabase/state/FacetActivity.java: + New. Implementors of this interface can decide if a facet should be initially + active or not. Contains a registry singleton. + 2012-07-27 Ingo Weinzierl Tagged trunk as '2.8.1' diff -r b4ed641f01db -r bd76529d612b artifact-database/src/main/java/de/intevation/artifactdatabase/state/FacetActivity.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifact-database/src/main/java/de/intevation/artifactdatabase/state/FacetActivity.java Sun Jul 29 09:37:55 2012 +0000 @@ -0,0 +1,58 @@ +package de.intevation.artifactdatabase.state; + +import de.intevation.artifacts.Artifact; + +import java.util.HashMap; +import java.util.Map; + +public interface FacetActivity +{ + public static final FacetActivity ACTIVE = new FacetActivity() { + @Override + public boolean isInitialActive( + Artifact artifact, + Facet facet, + String output + ) { + return true; + } + }; + + public static final FacetActivity INACTIVE = new FacetActivity() { + @Override + public boolean isInitialActive( + Artifact artifact, + Facet facet, + String output + ) { + return false; + } + }; + + boolean isInitialActive(Artifact artifact, Facet facet, String output); + + public static final class Registry { + + private static final Registry INSTANCE = new Registry(); + + private Map activities; + + private Registry() { + activities = new HashMap(); + } + + public Registry getInstance() { + return INSTANCE; + } + + public synchronized FacetActivity getActivity(String key) { + FacetActivity activity = activities.get(key); + return activity != null ? activity : ACTIVE; + } + + public synchronized void register(String key, FacetActivity activity) { + activities.put(key, activity); + } + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :