1
1
package org .woehlke .twitterwall .oodm .entities ;
2
2
3
- import org .hibernate .validator .constraints .SafeHtml ;
4
3
import org .woehlke .twitterwall .oodm .entities .common .DomainObjectEntity ;
5
4
import org .woehlke .twitterwall .oodm .entities .parts .AbstractDomainObject ;
6
5
import org .woehlke .twitterwall .oodm .entities .common .DomainObject ;
11
10
import javax .persistence .*;
12
11
import java .util .HashMap ;
13
12
import java .util .Map ;
14
- import java .util .regex .Matcher ;
15
- import java .util .regex .Pattern ;
16
13
17
14
/**
18
15
* Created by tw on 10.06.17.
27
24
@ NamedQueries ({
28
25
@ NamedQuery (
29
26
name ="HashTag.findByUniqueId" ,
30
- query ="select t from HashTag t where t.text=:text"
27
+ query ="select t from HashTag t where t.hashTagText. text=:text"
31
28
)
32
29
})
33
30
@ EntityListeners (HashTagListener .class )
@@ -40,24 +37,24 @@ public class HashTag extends AbstractDomainObject<HashTag> implements DomainObje
40
37
protected Long id ;
41
38
42
39
@ Embedded
43
- private HashTagText text ;
40
+ private HashTagText hashTagText ;
44
41
45
42
@ Column
46
43
private Long numberOfTweets ;
47
44
48
45
@ Column
49
46
private Long numberOfUsers ;
50
47
51
- public HashTag (Task createdBy , Task updatedBy , HashTagText text ,Long numberOfTweets , Long numberOfUsers ) {
48
+ public HashTag (Task createdBy , Task updatedBy , HashTagText hashTagText ,Long numberOfTweets , Long numberOfUsers ) {
52
49
super (createdBy ,updatedBy );
53
- this .text = text ;
50
+ this .hashTagText = hashTagText ;
54
51
this .numberOfTweets = numberOfTweets ;
55
52
this .numberOfUsers = numberOfUsers ;
56
53
}
57
54
58
- public HashTag (Task createdBy , Task updatedBy , HashTagText text ) {
55
+ public HashTag (Task createdBy , Task updatedBy , HashTagText hashTagText ) {
59
56
super (createdBy ,updatedBy );
60
- this .text = text ;
57
+ this .hashTagText = hashTagText ;
61
58
}
62
59
63
60
private HashTag () {
@@ -74,24 +71,24 @@ public void setId(Long id) {
74
71
75
72
@ Override
76
73
public boolean isValid () {
77
- if (this .text == null ){
74
+ if (this .hashTagText == null ){
78
75
return false ;
79
76
}
80
- if (!text .isValid ()){
77
+ if (!hashTagText .isValid ()){
81
78
return false ;
82
79
}
83
80
return true ;
84
81
}
85
82
86
83
@ Override
87
84
public String getUniqueId () {
88
- return this .getText ().getText ();
85
+ return this .getHashTagText ().getText ();
89
86
}
90
87
91
88
@ Override
92
89
public Map <String , Object > getParametersForFindByUniqueId () {
93
90
Map <String ,Object > parameters = new HashMap <>();
94
- parameters .put ("text" ,this .text );
91
+ parameters .put ("text" ,this .hashTagText . getText () );
95
92
return parameters ;
96
93
}
97
94
@@ -100,12 +97,12 @@ public String getQueryNameForFindByUniqueId() {
100
97
return "HashTag.findByUniqueId" ;
101
98
}
102
99
103
- public HashTagText getText () {
104
- return text ;
100
+ public HashTagText getHashTagText () {
101
+ return hashTagText ;
105
102
}
106
103
107
- public void setText (HashTagText text ) {
108
- this .text = text ;
104
+ public void setHashTagText (HashTagText hashTagText ) {
105
+ this .hashTagText = hashTagText ;
109
106
}
110
107
111
108
public static long getSerialVersionUID () {
@@ -136,30 +133,36 @@ public void increaseNumberOfUsers() {
136
133
this .numberOfUsers ++;
137
134
}
138
135
139
- @ Override
140
- public String toString () {
141
- return "HashTag{" +
142
- " id=" + id +
143
- ", text='" + text + '\'' +
144
- super .toString () +
145
- " }\n " ;
146
- }
147
-
148
136
@ Override
149
137
public boolean equals (Object o ) {
150
138
if (this == o ) return true ;
151
139
if (!(o instanceof HashTag )) return false ;
152
140
153
141
HashTag hashTag = (HashTag ) o ;
154
142
155
- if (getId () != null ? !getId ().equals (hashTag .getId ()) : hashTag .getId () != null ) return false ;
156
- return getText () != null ? getText ().equals (hashTag .getText ()) : hashTag .getText () == null ;
143
+ if (id != null ? !id .equals (hashTag .id ) : hashTag .id != null ) return false ;
144
+ if (hashTagText != null ? !hashTagText .equals (hashTag .hashTagText ) : hashTag .hashTagText != null ) return false ;
145
+ if (numberOfTweets != null ? !numberOfTweets .equals (hashTag .numberOfTweets ) : hashTag .numberOfTweets != null )
146
+ return false ;
147
+ return numberOfUsers != null ? numberOfUsers .equals (hashTag .numberOfUsers ) : hashTag .numberOfUsers == null ;
157
148
}
158
149
159
150
@ Override
160
151
public int hashCode () {
161
- int result = getId () != null ? getId ().hashCode () : 0 ;
162
- result = 31 * result + (getText () != null ? getText ().hashCode () : 0 );
152
+ int result = id != null ? id .hashCode () : 0 ;
153
+ result = 31 * result + (hashTagText != null ? hashTagText .hashCode () : 0 );
154
+ result = 31 * result + (numberOfTweets != null ? numberOfTweets .hashCode () : 0 );
155
+ result = 31 * result + (numberOfUsers != null ? numberOfUsers .hashCode () : 0 );
163
156
return result ;
164
157
}
158
+
159
+ @ Override
160
+ public String toString () {
161
+ return "HashTag{" +
162
+ "id=" + id +
163
+ ", hashTagText=" + hashTagText +
164
+ ", numberOfTweets=" + numberOfTweets +
165
+ ", numberOfUsers=" + numberOfUsers +
166
+ '}' ;
167
+ }
165
168
}
0 commit comments