source: josm/trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Subpart.java@ 10721

Last change on this file since 10721 was 10600, checked in by Don-vip, 8 years ago

see #11390 - sonar - squid:S1609 - Java 8: @FunctionalInterface annotation should be used to flag Single Abstract Method interfaces

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.mappaint.mapcss;
3
4import org.openstreetmap.josm.gui.mappaint.Cascade;
5import org.openstreetmap.josm.gui.mappaint.Environment;
6
7/**
8 * A subpart identifies different rendering layers (<code>::subpart</code> syntax).
9 * @since 8086 (creation)
10 * @since 10600 (functional interface)
11 */
12@FunctionalInterface
13public interface Subpart {
14 String getId(Environment env);
15
16 Subpart DEFAULT_SUBPART = new StringSubpart("default");
17
18 /**
19 * Simple static subpart identifier.
20 *
21 * E.g. ::layer_1
22 */
23 class StringSubpart implements Subpart {
24 private final String id;
25
26 public StringSubpart(String id) {
27 this.id = id;
28 }
29
30 @Override
31 public String getId(Environment env) {
32 return id;
33 }
34
35 @Override
36 public String toString() {
37 return id;
38 }
39 }
40
41 /**
42 * Subpart identifier given by an expression.
43 *
44 * E.g. ::(concat("layer_", prop("i", "default")))
45 */
46 class ExpressionSubpart implements Subpart {
47 private final Expression id;
48
49 public ExpressionSubpart(Expression id) {
50 this.id = id;
51 }
52
53 @Override
54 public String getId(Environment env) {
55 return Cascade.convertTo(id.evaluate(env), String.class);
56 }
57
58 @Override
59 public String toString() {
60 return String.valueOf(id);
61 }
62 }
63}
Note: See TracBrowser for help on using the repository browser.