Mercurial > dive4elements > framework
view artifact-database/src/main/java/de/intevation/artifactdatabase/state/FacetActivity.java @ 434:403a6793077c
Added tag flys-2.9.2 for changeset bd012f4720ae
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 03 Oct 2012 16:32:33 +0200 |
parents | e1738650bfca |
children | 15179c77aa1d |
line wrap: on
line source
package de.intevation.artifactdatabase.state; import de.intevation.artifacts.Artifact; import java.util.ArrayList; import java.util.HashMap; import java.util.List; 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 Boolean.TRUE; } }; public static final FacetActivity INACTIVE = new FacetActivity() { @Override public Boolean isInitialActive( Artifact artifact, Facet facet, String output ) { return Boolean.FALSE; } }; Boolean isInitialActive(Artifact artifact, Facet facet, String output); public static final class Registry { private static final Registry INSTANCE = new Registry(); private Map<String, List<FacetActivity>> activities; private Registry() { activities = new HashMap<String, List<FacetActivity>>(); } public static Registry getInstance() { return INSTANCE; } public synchronized boolean isInitialActive( String key, Artifact artifact, Facet facet, String output ) { List<FacetActivity> activityList = activities.get(key); if (activityList == null) { return true; } for (FacetActivity activity: activityList) { Boolean isActive = activity.isInitialActive(artifact, facet, output); if (isActive != null) { return isActive; } } return true; } public synchronized void register(String key, FacetActivity activity) { List<FacetActivity> activityList = activities.get(key); if (activityList == null) { activityList = new ArrayList<FacetActivity>(3); activities.put(key, activityList); } activityList.add(activity); } } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :