1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.codelibs.fess.dict.protwords;
17
18 import org.apache.commons.lang3.StringUtils;
19 import org.codelibs.core.lang.StringUtil;
20 import org.codelibs.fess.dict.DictionaryItem;
21
22 public class ProtwordsItem extends DictionaryItem {
23 private final String input;
24
25 private String newInput;
26
27 public ProtwordsItem(final long id, final String input) {
28 this.id = id;
29 this.input = input;
30
31 if (id == 0) {
32
33 newInput = input;
34 }
35 }
36
37 public String getNewInput() {
38 return newInput;
39 }
40
41 public void setNewInput(final String newInput) {
42 this.newInput = newInput;
43 }
44
45 public String getInput() {
46 return input;
47 }
48
49 public String getInputValue() {
50 if (input == null) {
51 return StringUtil.EMPTY;
52 }
53 return input;
54 }
55
56 public boolean isUpdated() {
57 return newInput != null;
58 }
59
60 public boolean isDeleted() {
61 return isUpdated() && newInput.length() == 0;
62 }
63
64 @Override
65 public int hashCode() {
66 final int prime = 31;
67 int result = 1;
68 result = prime * result + input.hashCode();
69 return result;
70 }
71
72 @Override
73 public boolean equals(final Object obj) {
74 if (this == obj) {
75 return true;
76 }
77 if (obj == null) {
78 return false;
79 }
80 if (getClass() != obj.getClass()) {
81 return false;
82 }
83 final ProtwordsItem other = (ProtwordsItem) obj;
84 if (!input.equals(other.input)) {
85 return false;
86 }
87 return true;
88 }
89
90 @Override
91 public String toString() {
92 return "ProtwordsItem [id=" + id + ", inputs=" + input + ", newInputs=" + newInput + "]";
93 }
94
95 public String toLineString() {
96 if (isUpdated()) {
97 return StringUtils.join(newInput);
98 }
99 return StringUtils.join(input);
100 }
101
102 }