Last change
on this file since 11615 was 10300, checked in by Don-vip, 8 years ago |
sonar - Performance - Method passes constant String of length 1 to character overridden method + add unit tests/javadoc
|
-
Property svn:eol-style
set to
native
|
File size:
962 bytes
|
Line | |
---|
1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.mappaint.mapcss;
|
---|
3 |
|
---|
4 | import java.util.Arrays;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.gui.mappaint.Environment;
|
---|
7 | import org.openstreetmap.josm.tools.CheckParameterUtil;
|
---|
8 |
|
---|
9 | /**
|
---|
10 | * Simple literal value, that does not depend on other expressions.
|
---|
11 | * @since 5705
|
---|
12 | */
|
---|
13 | public class LiteralExpression implements Expression {
|
---|
14 | private final Object literal;
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * Constructs a new {@code LiteralExpression}.
|
---|
18 | * @param literal literal
|
---|
19 | */
|
---|
20 | public LiteralExpression(Object literal) {
|
---|
21 | CheckParameterUtil.ensureParameterNotNull(literal);
|
---|
22 | this.literal = literal;
|
---|
23 | }
|
---|
24 |
|
---|
25 | @Override
|
---|
26 | public Object evaluate(Environment env) {
|
---|
27 | return literal;
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | public String toString() {
|
---|
32 | if (literal instanceof float[]) {
|
---|
33 | return Arrays.toString((float[]) literal);
|
---|
34 | }
|
---|
35 | return '<' + literal.toString() + '>';
|
---|
36 | }
|
---|
37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.