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