annotate artifacts/src/main/java/org/dive4elements/river/exports/GeneratorLookup.java @ 7228:3f141505077b

Global facet filtering with bound to out: The DiagramAttributes implements the FacetFilter and not the Generators.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 02 Oct 2013 23:11:59 +0200
parents 744df5a03337
children 9667900536b6
rev   line source
7226
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
2 * Software engineering by Intevation GmbH
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
3 *
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
6 * documentation coming with Dive4Elements River for details.
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
7 */
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
8
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
9 package org.dive4elements.river.exports;
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
10
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
11 import java.util.HashMap;
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
12 import java.util.Map;
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
13
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
14 import org.dive4elements.river.utils.Pair;
7227
744df5a03337 Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7226
diff changeset
15 import org.dive4elements.river.artifacts.D4EArtifact.FacetFilter;
7226
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
16
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
17 public class GeneratorLookup
7227
744df5a03337 Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7226
diff changeset
18 implements FacetFilter
7226
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
19 {
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
20 private Map<String, Pair<Class<OutGenerator>, Object>> generators;
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
21
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
22 public GeneratorLookup() {
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
23 generators = new HashMap<String, Pair<Class<OutGenerator>, Object>>();
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
24 }
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
25
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
26 public void putGenerator(
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
27 String outName,
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
28 Class<OutGenerator> generatorClass,
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
29 Object ctx
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
30 ) {
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
31 Pair<Class<OutGenerator>, Object> pair =
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
32 new Pair<Class<OutGenerator>, Object>(generatorClass, ctx);
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
33 generators.put(outName, pair);
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
34 }
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
35
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
36 public Pair<Class<OutGenerator>, Object> getGenerator(String outName) {
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
37 return generators.get(outName);
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
38 }
7227
744df5a03337 Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7226
diff changeset
39
744df5a03337 Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7226
diff changeset
40 @Override
744df5a03337 Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7226
diff changeset
41 public boolean accept(String outName, String facetName) {
744df5a03337 Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7226
diff changeset
42
744df5a03337 Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7226
diff changeset
43 Pair<Class<OutGenerator>, Object> pair = generators.get(outName);
744df5a03337 Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7226
diff changeset
44 if (pair == null) {
744df5a03337 Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7226
diff changeset
45 return true;
744df5a03337 Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7226
diff changeset
46 }
744df5a03337 Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7226
diff changeset
47
7228
3f141505077b Global facet filtering with bound to out: The DiagramAttributes implements the FacetFilter and not the Generators.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7227
diff changeset
48 Object ff = pair.getB();
3f141505077b Global facet filtering with bound to out: The DiagramAttributes implements the FacetFilter and not the Generators.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7227
diff changeset
49 return ff instanceof FacetFilter
3f141505077b Global facet filtering with bound to out: The DiagramAttributes implements the FacetFilter and not the Generators.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7227
diff changeset
50 ? ((FacetFilter)ff).accept(outName, facetName)
3f141505077b Global facet filtering with bound to out: The DiagramAttributes implements the FacetFilter and not the Generators.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7227
diff changeset
51 : true;
7227
744df5a03337 Use diagram configuration and there processors to define compatible facets in loaded data.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 7226
diff changeset
52 }
7226
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
53 }
8ab618dda850 Made lookup for generators a class of its own. First step to use it as a compat filter for facets, too.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
diff changeset
54 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org