source: josm/trunk/src/org/openstreetmap/josm/tools/template_engine/StaticText.java

Last change on this file was 16488, checked in by simon04, 4 years ago

fix #19281, see #19174 - Use Objects.hash where it is not used (patch by hiddewie, modified)

  • Property svn:eol-style set to native
File size: 1.4 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools.template_engine;
3
4import java.util.Objects;
5
6/**
7 * {@link TemplateEntry} representing a static string.
8 * <p>
9 * When compiling the template result, the given string will simply be inserted at the current position.
10 */
11public class StaticText implements TemplateEntry {
12
13 private final String staticText;
14
15 /**
16 * Create a new {@code StaticText}.
17 * @param staticText the text to insert verbatim
18 */
19 public StaticText(String staticText) {
20 this.staticText = staticText;
21 }
22
23 @Override
24 public void appendText(StringBuilder result, TemplateEngineDataProvider dataProvider) {
25 result.append(staticText);
26 }
27
28 @Override
29 public boolean isValid(TemplateEngineDataProvider dataProvider) {
30 return true;
31 }
32
33 @Override
34 public String toString() {
35 return staticText;
36 }
37
38 @Override
39 public int hashCode() {
40 return Objects.hash(staticText);
41 }
42
43 @Override
44 public boolean equals(Object obj) {
45 if (this == obj)
46 return true;
47 if (obj == null || getClass() != obj.getClass())
48 return false;
49 StaticText other = (StaticText) obj;
50 if (staticText == null) {
51 if (other.staticText != null)
52 return false;
53 } else if (!staticText.equals(other.staticText))
54 return false;
55 return true;
56 }
57}
Note: See TracBrowser for help on using the repository browser.