Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #26 from habuma/master

Polish, tests, code style, and Jackson mixins for entity types introduced in previously merged pull request.
  • Loading branch information...
commit 4260e3ed43d1ef352023114ac580e6001274c0db 2 parents a9c7bec + d917853
@habuma habuma authored
Showing with 1,386 additions and 1,139 deletions.
  1. +3 −1 build.gradle
  2. +122 −138 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/Entities.java
  3. +67 −72 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/HashTagEntity.java
  4. +134 −150 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/MediaEntity.java
  5. +99 −102 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/MentionEntity.java
  6. +165 −205 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/Tweet.java
  7. +149 −185 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/TwitterProfile.java
  8. +92 −100 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/UrlEntity.java
  9. +38 −0 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/impl/EntitiesMixin.java
  10. +30 −0 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/impl/HashTagEntityMixin.java
  11. +2 −0  spring-social-twitter/src/main/java/org/springframework/social/twitter/api/impl/ListTemplate.java
  12. +36 −0 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/impl/MediaEntityMixin.java
  13. +32 −0 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/impl/MentionEntityMixin.java
  14. +1 −9 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/impl/SearchTemplate.java
  15. +23 −32 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/impl/TimelineTemplate.java
  16. +57 −64 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/impl/TweetDeserializer.java
  17. +12 −0 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/impl/TwitterModule.java
  18. +0 −1  spring-social-twitter/src/main/java/org/springframework/social/twitter/api/impl/TwitterProfileMixin.java
  19. +5 −17 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/impl/TwitterTemplate.java
  20. +28 −0 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/impl/UrlEntityMixin.java
  21. +37 −0 spring-social-twitter/src/test/java/org/springframework/social/twitter/api/impl/AbstractTwitterApiTest.java
  22. +4 −4 spring-social-twitter/src/test/java/org/springframework/social/twitter/api/impl/ApiErrorTest.java
  23. +6 −6 spring-social-twitter/src/test/java/org/springframework/social/twitter/api/impl/ListsTemplateTest.java
  24. +46 −46 spring-social-twitter/src/test/java/org/springframework/social/twitter/api/impl/TimelineTemplateTest.java
  25. +51 −2 spring-social-twitter/src/test/java/org/springframework/social/twitter/api/impl/favorite.json
  26. +51 −2 spring-social-twitter/src/test/java/org/springframework/social/twitter/api/impl/search.json
  27. +45 −1 spring-social-twitter/src/test/java/org/springframework/social/twitter/api/impl/status.json
  28. +51 −2 spring-social-twitter/src/test/java/org/springframework/social/twitter/api/impl/timeline.json
View
4 build.gradle
@@ -19,6 +19,7 @@ configure(allprojects) {
ext {
springSocialVersion = '1.1.0.BUILD-SNAPSHOT'
+ hamcrestVersion = '1.3'
jacksonVersion = '1.9.9'
junitVersion = '4.10'
mockitoVersion = '1.9.0'
@@ -38,8 +39,9 @@ configure(allprojects) {
}
dependencies {
+ testCompile "org.hamcrest:hamcrest-library:$hamcrestVersion"
testCompile "junit:junit-dep:$junitVersion"
- testCompile "org.mockito:mockito-all:$mockitoVersion"
+ testCompile "org.mockito:mockito-core:$mockitoVersion"
testCompile "org.springframework:spring-test:$springVersion"
}
View
260 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/Entities.java
@@ -1,8 +1,20 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.social.twitter.api;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-
import java.io.Serializable;
import java.util.Collections;
import java.util.LinkedList;
@@ -14,139 +26,111 @@
* User: bowen
* Date: 12/26/11
*/
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class Entities implements Serializable
-{
- private static final long serialVersionUID = 1L;
-
- @JsonProperty("urls")
- private List<UrlEntity> urls = new LinkedList<UrlEntity>();
-
- @JsonProperty("hashtags")
- private List<HashTagEntity> tags = new LinkedList<HashTagEntity>();
-
- @JsonProperty("user_mentions")
- private List<MentionEntity> mentions = new LinkedList<MentionEntity>();
-
- @JsonProperty("media")
- private List<MediaEntity> media = new LinkedList<MediaEntity>();
-
-
- /**
- * JSON constructor.
- */
- public Entities()
- {
-
- }
-
-
- public List<UrlEntity> getUrls()
- {
- if (this.urls == null)
- {
- return Collections.emptyList();
- }
- return this.urls;
- }
-
-
- public List<HashTagEntity> getTags()
- {
- if (this.tags == null)
- {
- return Collections.emptyList();
- }
- return this.tags;
- }
-
-
- public List<MentionEntity> getMentions()
- {
- if (this.mentions == null)
- {
- return Collections.emptyList();
- }
- return this.mentions;
- }
-
-
- public List<MediaEntity> getMedia()
- {
- if (this.media == null)
- {
- return Collections.emptyList();
- }
- return this.media;
- }
-
-
- public boolean hasUrls()
- {
- return this.urls != null && !this.urls.isEmpty();
- }
-
-
- public boolean hasTags()
- {
- return this.tags != null && !this.tags.isEmpty();
- }
-
-
- public boolean hasMentions()
- {
- return this.mentions != null && !this.mentions.isEmpty();
- }
-
-
- public boolean hasMedia()
- {
- return this.media != null && !this.media.isEmpty();
- }
-
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- Entities entities = (Entities) o;
-
- if (media != null ? !media.equals(entities.media) : entities.media != null)
- {
- return false;
- }
- if (mentions != null ? !mentions.equals(entities.mentions) : entities.mentions != null)
- {
- return false;
- }
- if (tags != null ? !tags.equals(entities.tags) : entities.tags != null)
- {
- return false;
- }
- if (urls != null ? !urls.equals(entities.urls) : entities.urls != null)
- {
- return false;
- }
-
- return true;
- }
-
-
- @Override
- public int hashCode()
- {
- int result = urls != null ? urls.hashCode() : 0;
- result = 31 * result + (tags != null ? tags.hashCode() : 0);
- result = 31 * result + (mentions != null ? mentions.hashCode() : 0);
- result = 31 * result + (media != null ? media.hashCode() : 0);
- return result;
- }
+public class Entities implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private List<UrlEntity> urls = new LinkedList<UrlEntity>();
+
+ private List<HashTagEntity> tags = new LinkedList<HashTagEntity>();
+
+ private List<MentionEntity> mentions = new LinkedList<MentionEntity>();
+
+ private List<MediaEntity> media = new LinkedList<MediaEntity>();
+
+ public Entities(List<UrlEntity> urls, List<HashTagEntity> tags, List<MentionEntity> mentions, List<MediaEntity> media) {
+ this.urls = urls;
+ this.tags = tags;
+ this.mentions = mentions;
+ this.media = media;
+ }
+
+
+ public List<UrlEntity> getUrls() {
+ if (this.urls == null) {
+ return Collections.emptyList();
+ }
+ return this.urls;
+ }
+
+
+ public List<HashTagEntity> getHashTags() {
+ if (this.tags == null) {
+ return Collections.emptyList();
+ }
+ return this.tags;
+ }
+
+
+ public List<MentionEntity> getMentions() {
+ if (this.mentions == null) {
+ return Collections.emptyList();
+ }
+ return this.mentions;
+ }
+
+
+ public List<MediaEntity> getMedia() {
+ if (this.media == null) {
+ return Collections.emptyList();
+ }
+ return this.media;
+ }
+
+
+ public boolean hasUrls() {
+ return this.urls != null && !this.urls.isEmpty();
+ }
+
+
+ public boolean hasTags() {
+ return this.tags != null && !this.tags.isEmpty();
+ }
+
+
+ public boolean hasMentions() {
+ return this.mentions != null && !this.mentions.isEmpty();
+ }
+
+
+ public boolean hasMedia() {
+ return this.media != null && !this.media.isEmpty();
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ Entities entities = (Entities) o;
+ if (media != null ? !media.equals(entities.media) : entities.media != null) {
+ return false;
+ }
+ if (mentions != null ? !mentions.equals(entities.mentions) : entities.mentions != null) {
+ return false;
+ }
+ if (tags != null ? !tags.equals(entities.tags) : entities.tags != null) {
+ return false;
+ }
+ if (urls != null ? !urls.equals(entities.urls) : entities.urls != null) {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ @Override
+ public int hashCode() {
+ int result = urls != null ? urls.hashCode() : 0;
+ result = 31 * result + (tags != null ? tags.hashCode() : 0);
+ result = 31 * result + (mentions != null ? mentions.hashCode() : 0);
+ result = 31 * result + (media != null ? media.hashCode() : 0);
+ return result;
+ }
}
View
139 ...ng-social-twitter/src/main/java/org/springframework/social/twitter/api/HashTagEntity.java
@@ -1,7 +1,20 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.social.twitter.api;
-import org.codehaus.jackson.annotate.JsonProperty;
-
import java.io.Serializable;
import java.util.Arrays;
@@ -11,74 +24,56 @@
* User: bowen
* Date: 12/26/11
*/
-public class HashTagEntity implements Serializable
-{
- private static final long serialVersionUID = 1L;
-
- @JsonProperty("text")
- private String text;
-
- @JsonProperty("indices")
- private int[] indices;
-
-
- /**
- * JSON constructor.
- */
- public HashTagEntity()
- {
-
- }
-
-
- public String getText()
- {
- return this.text;
- }
-
-
- public int[] getIndices()
- {
- if (this.indices == null || this.indices.length <= 0)
- {
- return new int[0];
- }
- return this.indices;
- }
-
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- HashTagEntity that = (HashTagEntity) o;
-
- if (!Arrays.equals(indices, that.indices))
- {
- return false;
- }
- if (text != null ? !text.equals(that.text) : that.text != null)
- {
- return false;
- }
-
- return true;
- }
-
-
- @Override
- public int hashCode()
- {
- int result = text != null ? text.hashCode() : 0;
- result = 31 * result + (indices != null ? Arrays.hashCode(indices) : 0);
- return result;
- }
+public class HashTagEntity implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ private String text;
+
+ private int[] indices;
+
+ public String getText() {
+ return this.text;
+ }
+
+ public HashTagEntity(String text, int[] indices) {
+ this.text = text;
+ this.indices = indices;
+ }
+
+ public int[] getIndices() {
+ if (this.indices == null || this.indices.length <= 0) {
+ return new int[0];
+ }
+ return this.indices;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ HashTagEntity that = (HashTagEntity) o;
+
+ if (!Arrays.equals(indices, that.indices)) {
+ return false;
+ }
+ if (text != null ? !text.equals(that.text) : that.text != null) {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ @Override
+ public int hashCode() {
+ int result = text != null ? text.hashCode() : 0;
+ result = 31 * result + (indices != null ? Arrays.hashCode(indices) : 0);
+ return result;
+ }
}
View
284 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/MediaEntity.java
@@ -1,8 +1,20 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.social.twitter.api;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-
import java.io.Serializable;
import java.util.Arrays;
@@ -12,159 +24,131 @@
* User: bowen
* Date: 12/26/11
*/
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class MediaEntity implements Serializable
-{
- private static final long serialVersionUID = 1L;
+public class MediaEntity implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private long id;
+
+ private String mediaHttp;
+
+ private String mediaHttps;
+
+ private String url;
+
+ private String display;
+
+ private String expanded;
+
+ private String type;
+
+ private int[] indices;
+
+ public MediaEntity(long id, String mediaHttp, String mediaHttps, String url, String display, String expanded, String type, int[] indices) {
+ this.id = id;
+ this.mediaHttp = mediaHttp;
+ this.mediaHttps = mediaHttps;
+ this.url = url;
+ this.display = display;
+ this.expanded = expanded;
+ this.type = type;
+ this.indices = indices;
+ }
+
+
+ public long getId() {
+ return this.id;
+ }
+
+
+ public String getMediaUrl() {
+ return this.mediaHttp;
+ }
+
+
+ public String getMediaSecureUrl() {
+ return this.mediaHttps;
+ }
+
+
+ public String getType() {
+ return this.type;
+ }
+
+
+ public String getDisplayUrl() {
+ return display;
+ }
+
+
+ public String getExpandedUrl() {
+ return this.expanded;
+ }
- @JsonProperty("id")
- private long id;
- @JsonProperty("media_url")
- private String mediaHttp;
+ public String getUrl() {
+ return this.url;
+ }
- @JsonProperty("media_url_https")
- private String mediaHttps;
- @JsonProperty("url")
- private String url;
+ public int[] getIndices() {
+ if (this.indices == null || this.indices.length <= 0) {
+ return new int[0];
+ }
+ return this.indices;
+ }
- @JsonProperty("display_url")
- private String display;
- @JsonProperty("expanded_url")
- private String expanded;
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
- @JsonProperty("type")
- private String type;
+ MediaEntity that = (MediaEntity) o;
- @JsonProperty("indices")
- private int[] indices;
-
-
- /**
- * JSON constructor.
- */
- public MediaEntity()
- {
-
- }
-
-
- public long getId()
- {
- return this.id;
- }
-
-
- public String getMediaUrl()
- {
- return this.mediaHttp;
- }
-
-
- public String getMediaSecureUrl()
- {
- return this.mediaHttps;
- }
-
-
- public String getType()
- {
- return this.type;
- }
-
-
- public String getDisplayUrl()
- {
- return display;
- }
-
-
- public String getExpandedUrl()
- {
- return this.expanded;
- }
-
-
- public String getUrl()
- {
- return this.url;
- }
-
-
- public int[] getIndices()
- {
- if (this.indices == null || this.indices.length <= 0)
- {
- return new int[0];
- }
- return this.indices;
- }
-
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- MediaEntity that = (MediaEntity) o;
-
- if (id != that.id)
- {
- return false;
- }
- if (display != null ? !display.equals(that.display) : that.display != null)
- {
- return false;
- }
- if (expanded != null ? !expanded.equals(that.expanded) : that.expanded != null)
- {
- return false;
- }
- if (!Arrays.equals(indices, that.indices))
- {
- return false;
- }
- if (mediaHttp != null ? !mediaHttp.equals(that.mediaHttp) : that.mediaHttp != null)
- {
- return false;
- }
- if (mediaHttps != null ? !mediaHttps.equals(that.mediaHttps) : that.mediaHttps != null)
- {
- return false;
- }
- if (type != null ? !type.equals(that.type) : that.type != null)
- {
- return false;
- }
- if (url != null ? !url.equals(that.url) : that.url != null)
- {
- return false;
- }
-
- return true;
- }
-
-
- @Override
- public int hashCode()
- {
- int result = (int) (id ^ (id >>> 32));
- result = 31 * result + (mediaHttp != null ? mediaHttp.hashCode() : 0);
- result = 31 * result + (mediaHttps != null ? mediaHttps.hashCode() : 0);
- result = 31 * result + (url != null ? url.hashCode() : 0);
- result = 31 * result + (display != null ? display.hashCode() : 0);
- result = 31 * result + (expanded != null ? expanded.hashCode() : 0);
- result = 31 * result + (type != null ? type.hashCode() : 0);
- result = 31 * result + (indices != null ? Arrays.hashCode(indices) : 0);
- return result;
- }
+ if (id != that.id) {
+ return false;
+ }
+ if (display != null ? !display.equals(that.display) : that.display != null) {
+ return false;
+ }
+ if (expanded != null ? !expanded.equals(that.expanded) : that.expanded != null) {
+ return false;
+ }
+ if (!Arrays.equals(indices, that.indices)) {
+ return false;
+ }
+ if (mediaHttp != null ? !mediaHttp.equals(that.mediaHttp) : that.mediaHttp != null) {
+ return false;
+ }
+ if (mediaHttps != null ? !mediaHttps.equals(that.mediaHttps) : that.mediaHttps != null) {
+ return false;
+ }
+ if (type != null ? !type.equals(that.type) : that.type != null) {
+ return false;
+ }
+ if (url != null ? !url.equals(that.url) : that.url != null) {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ @Override
+ public int hashCode() {
+ int result = (int) (id ^ (id >>> 32));
+ result = 31 * result + (mediaHttp != null ? mediaHttp.hashCode() : 0);
+ result = 31 * result + (mediaHttps != null ? mediaHttps.hashCode() : 0);
+ result = 31 * result + (url != null ? url.hashCode() : 0);
+ result = 31 * result + (display != null ? display.hashCode() : 0);
+ result = 31 * result + (expanded != null ? expanded.hashCode() : 0);
+ result = 31 * result + (type != null ? type.hashCode() : 0);
+ result = 31 * result + (indices != null ? Arrays.hashCode(indices) : 0);
+ return result;
+ }
}
View
201 ...ng-social-twitter/src/main/java/org/springframework/social/twitter/api/MentionEntity.java
@@ -1,114 +1,111 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.social.twitter.api;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-
import java.io.Serializable;
import java.util.Arrays;
+import org.codehaus.jackson.annotate.JsonProperty;
+
/**
* A user mention entity.
* <p/>
* User: bowen
* Date: 12/26/11
*/
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class MentionEntity implements Serializable
-{
- private static final long serialVersionUID = 1L;
-
- @JsonProperty("id")
- private long id;
-
- @JsonProperty("screen_name")
- private String screenName;
-
- @JsonProperty("name")
- private String name;
-
- @JsonProperty("indices")
- private int[] indices;
-
-
- /**
- * JSON constructor.
- */
- public MentionEntity()
- {
-
- }
-
-
- public long getId()
- {
- return this.id;
- }
-
-
- public String getName()
- {
- return this.name;
- }
-
-
- public String getScreenName()
- {
- return this.screenName;
- }
-
-
- public int[] getIndices()
- {
- if (this.indices == null || this.indices.length <= 0)
- {
- return new int[0];
- }
- return this.indices;
- }
-
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- MentionEntity that = (MentionEntity) o;
-
- if (id != that.id)
- {
- return false;
- }
- if (name != null ? !name.equals(that.name) : that.name != null)
- {
- return false;
- }
- if (!Arrays.equals(indices, that.indices))
- {
- return false;
- }
- if (screenName != null ? !screenName.equals(that.screenName) : that.screenName != null)
- {
- return false;
- }
-
- return true;
- }
-
-
- @Override
- public int hashCode()
- {
- int result = (int) (id ^ (id >>> 32));
- result = 31 * result + (screenName != null ? screenName.hashCode() : 0);
- result = 31 * result + (name != null ? name.hashCode() : 0);
- result = 31 * result + (indices != null ? Arrays.hashCode(indices) : 0);
- return result;
- }
+public class MentionEntity implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @JsonProperty("id")
+ private long id;
+
+ @JsonProperty("screen_name")
+ private String screenName;
+
+ @JsonProperty("name")
+ private String name;
+
+ @JsonProperty("indices")
+ private int[] indices;
+
+ public MentionEntity(long id, String screenName, String name, int[] indices) {
+ this.id = id;
+ this.screenName = screenName;
+ this.name = name;
+ this.indices = indices;
+ }
+
+
+ public long getId() {
+ return this.id;
+ }
+
+
+ public String getName() {
+ return this.name;
+ }
+
+
+ public String getScreenName() {
+ return this.screenName;
+ }
+
+
+ public int[] getIndices() {
+ if (this.indices == null || this.indices.length <= 0) {
+ return new int[0];
+ }
+ return this.indices;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ MentionEntity that = (MentionEntity) o;
+
+ if (id != that.id) {
+ return false;
+ }
+ if (name != null ? !name.equals(that.name) : that.name != null) {
+ return false;
+ }
+ if (!Arrays.equals(indices, that.indices)) {
+ return false;
+ }
+ if (screenName != null ? !screenName.equals(that.screenName) : that.screenName != null) {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ @Override
+ public int hashCode() {
+ int result = (int) (id ^ (id >>> 32));
+ result = 31 * result + (screenName != null ? screenName.hashCode() : 0);
+ result = 31 * result + (name != null ? name.hashCode() : 0);
+ result = 31 * result + (indices != null ? Arrays.hashCode(indices) : 0);
+ return result;
+ }
}
View
370 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/Tweet.java
@@ -23,7 +23,7 @@
* @author Craig Walls
*/
public class Tweet implements Serializable {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
private final long id;
private final String text;
@@ -32,16 +32,16 @@
private String profileImageUrl;
private Long toUserId;
private Long inReplyToStatusId;
- private Long inReplyToUserId;
- private String inReplyToScreenName;
+ private Long inReplyToUserId;
+ private String inReplyToScreenName;
private long fromUserId;
private String languageCode;
private String source;
private Integer retweetCount;
private boolean retweeted;
- private Tweet retweetedStatus;
- private Entities entities;
- private TwitterProfile user;
+ private Tweet retweetedStatus;
+ private Entities entities;
+ private TwitterProfile user;
public Tweet(long id, String text, Date createdAt, String fromUser, String profileImageUrl, Long toUserId, long fromUserId, String languageCode, String source) {
this.id = id;
@@ -144,203 +144,163 @@ public boolean isRetweeted() {
return retweeted;
}
- public Tweet getRetweetedStatus()
- {
- return this.retweetedStatus;
- }
-
- public void setRetweetedStatus(final Tweet tweet)
- {
- this.retweetedStatus = tweet;
- }
-
- public boolean isRetweet()
- {
- return this.retweetedStatus != null;
- }
-
- public Entities getEntities()
- {
- return this.entities;
- }
-
- public void setEntities(final Entities ent)
- {
- this.entities = ent;
- }
-
- public boolean hasMentions()
- {
- if (this.entities == null)
- {
- return false;
- }
- return !this.entities.getMentions().isEmpty();
- }
-
- public boolean hasMedia()
- {
- if (this.entities == null)
- {
- return false;
- }
- return !this.entities.getMedia().isEmpty();
- }
-
- public boolean hasUrls()
- {
- if (this.entities == null)
- {
- return false;
- }
- return !this.entities.getUrls().isEmpty();
- }
-
- public boolean hasTags()
- {
- if (this.entities == null)
- {
- return false;
- }
- return !this.entities.getTags().isEmpty();
- }
-
- public TwitterProfile getUser()
- {
- return this.user;
- }
-
- public void setUser(final TwitterProfile prof)
- {
- this.user = prof;
- }
-
- public Long getInReplyToUserId()
- {
- return inReplyToUserId;
- }
-
- public void setInReplyToUserId(final Long inReplyToUserId)
- {
- this.inReplyToUserId = inReplyToUserId;
- }
-
- public String getInReplyToScreenName()
- {
- return inReplyToScreenName;
- }
-
- public void setInReplyToScreenName(final String inReplyToScreenName)
- {
- this.inReplyToScreenName = inReplyToScreenName;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- Tweet tweet = (Tweet) o;
-
- if (fromUserId != tweet.fromUserId)
- {
- return false;
- }
- if (id != tweet.id)
- {
- return false;
- }
- if (retweeted != tweet.retweeted)
- {
- return false;
- }
- if (createdAt != null ? !createdAt.equals(tweet.createdAt) : tweet.createdAt != null)
- {
- return false;
- }
- if (entities != null ? !entities.equals(tweet.entities) : tweet.entities != null)
- {
- return false;
- }
- if (fromUser != null ? !fromUser.equals(tweet.fromUser) : tweet.fromUser != null)
- {
- return false;
- }
- if (inReplyToScreenName != null ? !inReplyToScreenName.equals(tweet.inReplyToScreenName) : tweet.inReplyToScreenName != null)
- {
- return false;
- }
- if (inReplyToStatusId != null ? !inReplyToStatusId.equals(tweet.inReplyToStatusId) : tweet.inReplyToStatusId != null)
- {
- return false;
- }
- if (inReplyToUserId != null ? !inReplyToUserId.equals(tweet.inReplyToUserId) : tweet.inReplyToUserId != null)
- {
- return false;
- }
- if (languageCode != null ? !languageCode.equals(tweet.languageCode) : tweet.languageCode != null)
- {
- return false;
- }
- if (profileImageUrl != null ? !profileImageUrl.equals(tweet.profileImageUrl) : tweet.profileImageUrl != null)
- {
- return false;
- }
- if (retweetCount != null ? !retweetCount.equals(tweet.retweetCount) : tweet.retweetCount != null)
- {
- return false;
- }
- if (retweetedStatus != null ? !retweetedStatus.equals(tweet.retweetedStatus) : tweet.retweetedStatus != null)
- {
- return false;
- }
- if (source != null ? !source.equals(tweet.source) : tweet.source != null)
- {
- return false;
- }
- if (text != null ? !text.equals(tweet.text) : tweet.text != null)
- {
- return false;
- }
- if (toUserId != null ? !toUserId.equals(tweet.toUserId) : tweet.toUserId != null)
- {
- return false;
- }
- if (user != null ? !user.equals(tweet.user) : tweet.user != null)
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = (int) (id ^ (id >>> 32));
- result = 31 * result + (text != null ? text.hashCode() : 0);
- result = 31 * result + (createdAt != null ? createdAt.hashCode() : 0);
- result = 31 * result + (fromUser != null ? fromUser.hashCode() : 0);
- result = 31 * result + (profileImageUrl != null ? profileImageUrl.hashCode() : 0);
- result = 31 * result + (toUserId != null ? toUserId.hashCode() : 0);
- result = 31 * result + (inReplyToStatusId != null ? inReplyToStatusId.hashCode() : 0);
- result = 31 * result + (inReplyToUserId != null ? inReplyToUserId.hashCode() : 0);
- result = 31 * result + (inReplyToScreenName != null ? inReplyToScreenName.hashCode() : 0);
- result = 31 * result + (int) (fromUserId ^ (fromUserId >>> 32));
- result = 31 * result + (languageCode != null ? languageCode.hashCode() : 0);
- result = 31 * result + (source != null ? source.hashCode() : 0);
- result = 31 * result + (retweetCount != null ? retweetCount.hashCode() : 0);
- result = 31 * result + (retweeted ? 1 : 0);
- result = 31 * result + (retweetedStatus != null ? retweetedStatus.hashCode() : 0);
- result = 31 * result + (entities != null ? entities.hashCode() : 0);
- result = 31 * result + (user != null ? user.hashCode() : 0);
- return result;
- }
+ public Tweet getRetweetedStatus() {
+ return this.retweetedStatus;
+ }
+
+ public void setRetweetedStatus(final Tweet tweet) {
+ this.retweetedStatus = tweet;
+ }
+
+ public boolean isRetweet() {
+ return this.retweetedStatus != null;
+ }
+
+ public Entities getEntities() {
+ return this.entities;
+ }
+
+ public void setEntities(final Entities ent) {
+ this.entities = ent;
+ }
+
+ public boolean hasMentions() {
+ if (this.entities == null) {
+ return false;
+ }
+ return !this.entities.getMentions().isEmpty();
+ }
+
+ public boolean hasMedia() {
+ if (this.entities == null) {
+ return false;
+ }
+ return !this.entities.getMedia().isEmpty();
+ }
+
+ public boolean hasUrls() {
+ if (this.entities == null) {
+ return false;
+ }
+ return !this.entities.getUrls().isEmpty();
+ }
+
+ public boolean hasTags() {
+ if (this.entities == null) {
+ return false;
+ }
+ return !this.entities.getHashTags().isEmpty();
+ }
+
+ public TwitterProfile getUser() {
+ return this.user;
+ }
+
+ public void setUser(final TwitterProfile prof) {
+ this.user = prof;
+ }
+
+ public Long getInReplyToUserId() {
+ return inReplyToUserId;
+ }
+
+ public void setInReplyToUserId(final Long inReplyToUserId) {
+ this.inReplyToUserId = inReplyToUserId;
+ }
+
+ public String getInReplyToScreenName() {
+ return inReplyToScreenName;
+ }
+
+ public void setInReplyToScreenName(final String inReplyToScreenName) {
+ this.inReplyToScreenName = inReplyToScreenName;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ Tweet tweet = (Tweet) o;
+
+ if (fromUserId != tweet.fromUserId) {
+ return false;
+ }
+ if (id != tweet.id) {
+ return false;
+ }
+ if (retweeted != tweet.retweeted) {
+ return false;
+ }
+ if (createdAt != null ? !createdAt.equals(tweet.createdAt) : tweet.createdAt != null) {
+ return false;
+ }
+ if (entities != null ? !entities.equals(tweet.entities) : tweet.entities != null) {
+ return false;
+ }
+ if (fromUser != null ? !fromUser.equals(tweet.fromUser) : tweet.fromUser != null) {
+ return false;
+ }
+ if (inReplyToScreenName != null ? !inReplyToScreenName.equals(tweet.inReplyToScreenName) : tweet.inReplyToScreenName != null) {
+ return false;
+ }
+ if (inReplyToStatusId != null ? !inReplyToStatusId.equals(tweet.inReplyToStatusId) : tweet.inReplyToStatusId != null) {
+ return false;
+ }
+ if (inReplyToUserId != null ? !inReplyToUserId.equals(tweet.inReplyToUserId) : tweet.inReplyToUserId != null) {
+ return false;
+ }
+ if (languageCode != null ? !languageCode.equals(tweet.languageCode) : tweet.languageCode != null) {
+ return false;
+ }
+ if (profileImageUrl != null ? !profileImageUrl.equals(tweet.profileImageUrl) : tweet.profileImageUrl != null) {
+ return false;
+ }
+ if (retweetCount != null ? !retweetCount.equals(tweet.retweetCount) : tweet.retweetCount != null) {
+ return false;
+ }
+ if (retweetedStatus != null ? !retweetedStatus.equals(tweet.retweetedStatus) : tweet.retweetedStatus != null) {
+ return false;
+ }
+ if (source != null ? !source.equals(tweet.source) : tweet.source != null) {
+ return false;
+ }
+ if (text != null ? !text.equals(tweet.text) : tweet.text != null) {
+ return false;
+ }
+ if (toUserId != null ? !toUserId.equals(tweet.toUserId) : tweet.toUserId != null) {
+ return false;
+ }
+ if (user != null ? !user.equals(tweet.user) : tweet.user != null) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = (int) (id ^ (id >>> 32));
+ result = 31 * result + (text != null ? text.hashCode() : 0);
+ result = 31 * result + (createdAt != null ? createdAt.hashCode() : 0);
+ result = 31 * result + (fromUser != null ? fromUser.hashCode() : 0);
+ result = 31 * result + (profileImageUrl != null ? profileImageUrl.hashCode() : 0);
+ result = 31 * result + (toUserId != null ? toUserId.hashCode() : 0);
+ result = 31 * result + (inReplyToStatusId != null ? inReplyToStatusId.hashCode() : 0);
+ result = 31 * result + (inReplyToUserId != null ? inReplyToUserId.hashCode() : 0);
+ result = 31 * result + (inReplyToScreenName != null ? inReplyToScreenName.hashCode() : 0);
+ result = 31 * result + (int) (fromUserId ^ (fromUserId >>> 32));
+ result = 31 * result + (languageCode != null ? languageCode.hashCode() : 0);
+ result = 31 * result + (source != null ? source.hashCode() : 0);
+ result = 31 * result + (retweetCount != null ? retweetCount.hashCode() : 0);
+ result = 31 * result + (retweeted ? 1 : 0);
+ result = 31 * result + (retweetedStatus != null ? retweetedStatus.hashCode() : 0);
+ result = 31 * result + (entities != null ? entities.hashCode() : 0);
+ result = 31 * result + (user != null ? user.hashCode() : 0);
+ return result;
+ }
}
View
334 ...g-social-twitter/src/main/java/org/springframework/social/twitter/api/TwitterProfile.java
@@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -337,193 +337,157 @@ public boolean showAllInlineMedia() {
return showAllInlineMedia;
}
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
- TwitterProfile that = (TwitterProfile) o;
+ TwitterProfile that = (TwitterProfile) o;
- if (backgroundImageTiled != that.backgroundImageTiled)
- {
- return false;
- }
- if (contributorsEnabled != that.contributorsEnabled)
- {
- return false;
- }
- if (favoritesCount != that.favoritesCount)
- {
- return false;
- }
- if (followRequestSent != that.followRequestSent)
- {
- return false;
- }
- if (followersCount != that.followersCount)
- {
- return false;
- }
- if (following != that.following)
- {
- return false;
- }
- if (friendsCount != that.friendsCount)
- {
- return false;
- }
- if (geoEnabled != that.geoEnabled)
- {
- return false;
- }
- if (id != that.id)
- {
- return false;
- }
- if (isProtected != that.isProtected)
- {
- return false;
- }
- if (listedCount != that.listedCount)
- {
- return false;
- }
- if (notificationsEnabled != that.notificationsEnabled)
- {
- return false;
- }
- if (showAllInlineMedia != that.showAllInlineMedia)
- {
- return false;
- }
- if (statusesCount != that.statusesCount)
- {
- return false;
- }
- if (translator != that.translator)
- {
- return false;
- }
- if (useBackgroundImage != that.useBackgroundImage)
- {
- return false;
- }
- if (utcOffset != that.utcOffset)
- {
- return false;
- }
- if (verified != that.verified)
- {
- return false;
- }
- if (backgroundColor != null ? !backgroundColor.equals(that.backgroundColor) : that.backgroundColor != null)
- {
- return false;
- }
- if (backgroundImageUrl != null ? !backgroundImageUrl.equals(that.backgroundImageUrl) : that.backgroundImageUrl != null)
- {
- return false;
- }
- if (createdDate != null ? !createdDate.equals(that.createdDate) : that.createdDate != null)
- {
- return false;
- }
- if (description != null ? !description.equals(that.description) : that.description != null)
- {
- return false;
- }
- if (language != null ? !language.equals(that.language) : that.language != null)
- {
- return false;
- }
- if (linkColor != null ? !linkColor.equals(that.linkColor) : that.linkColor != null)
- {
- return false;
- }
- if (location != null ? !location.equals(that.location) : that.location != null)
- {
- return false;
- }
- if (name != null ? !name.equals(that.name) : that.name != null)
- {
- return false;
- }
- if (profileImageUrl != null ? !profileImageUrl.equals(that.profileImageUrl) : that.profileImageUrl != null)
- {
- return false;
- }
- if (screenName != null ? !screenName.equals(that.screenName) : that.screenName != null)
- {
- return false;
- }
- if (sidebarBorderColor != null ? !sidebarBorderColor.equals(that.sidebarBorderColor) : that.sidebarBorderColor != null)
- {
- return false;
- }
- if (sidebarFillColor != null ? !sidebarFillColor.equals(that.sidebarFillColor) : that.sidebarFillColor != null)
- {
- return false;
- }
- if (textColor != null ? !textColor.equals(that.textColor) : that.textColor != null)
- {
- return false;
- }
- if (timeZone != null ? !timeZone.equals(that.timeZone) : that.timeZone != null)
- {
- return false;
- }
- if (url != null ? !url.equals(that.url) : that.url != null)
- {
- return false;
- }
+ if (backgroundImageTiled != that.backgroundImageTiled) {
+ return false;
+ }
+ if (contributorsEnabled != that.contributorsEnabled) {
+ return false;
+ }
+ if (favoritesCount != that.favoritesCount) {
+ return false;
+ }
+ if (followRequestSent != that.followRequestSent) {
+ return false;
+ }
+ if (followersCount != that.followersCount) {
+ return false;
+ }
+ if (following != that.following) {
+ return false;
+ }
+ if (friendsCount != that.friendsCount) {
+ return false;
+ }
+ if (geoEnabled != that.geoEnabled) {
+ return false;
+ }
+ if (id != that.id) {
+ return false;
+ }
+ if (isProtected != that.isProtected) {
+ return false;
+ }
+ if (listedCount != that.listedCount) {
+ return false;
+ }
+ if (notificationsEnabled != that.notificationsEnabled) {
+ return false;
+ }
+ if (showAllInlineMedia != that.showAllInlineMedia) {
+ return false;
+ }
+ if (statusesCount != that.statusesCount) {
+ return false;
+ }
+ if (translator != that.translator) {
+ return false;
+ }
+ if (useBackgroundImage != that.useBackgroundImage) {
+ return false;
+ }
+ if (utcOffset != that.utcOffset) {
+ return false;
+ }
+ if (verified != that.verified) {
+ return false;
+ }
+ if (backgroundColor != null ? !backgroundColor.equals(that.backgroundColor) : that.backgroundColor != null) {
+ return false;
+ }
+ if (backgroundImageUrl != null ? !backgroundImageUrl.equals(that.backgroundImageUrl) : that.backgroundImageUrl != null) {
+ return false;
+ }
+ if (createdDate != null ? !createdDate.equals(that.createdDate) : that.createdDate != null) {
+ return false;
+ }
+ if (description != null ? !description.equals(that.description) : that.description != null) {
+ return false;
+ }
+ if (language != null ? !language.equals(that.language) : that.language != null) {
+ return false;
+ }
+ if (linkColor != null ? !linkColor.equals(that.linkColor) : that.linkColor != null) {
+ return false;
+ }
+ if (location != null ? !location.equals(that.location) : that.location != null) {
+ return false;
+ }
+ if (name != null ? !name.equals(that.name) : that.name != null) {
+ return false;
+ }
+ if (profileImageUrl != null ? !profileImageUrl.equals(that.profileImageUrl) : that.profileImageUrl != null) {
+ return false;
+ }
+ if (screenName != null ? !screenName.equals(that.screenName) : that.screenName != null) {
+ return false;
+ }
+ if (sidebarBorderColor != null ? !sidebarBorderColor.equals(that.sidebarBorderColor) : that.sidebarBorderColor != null) {
+ return false;
+ }
+ if (sidebarFillColor != null ? !sidebarFillColor.equals(that.sidebarFillColor) : that.sidebarFillColor != null) {
+ return false;
+ }
+ if (textColor != null ? !textColor.equals(that.textColor) : that.textColor != null) {
+ return false;
+ }
+ if (timeZone != null ? !timeZone.equals(that.timeZone) : that.timeZone != null) {
+ return false;
+ }
+ if (url != null ? !url.equals(that.url) : that.url != null) {
+ return false;
+ }
+
+ return true;
+ }
- return true;
- }
+ @Override
+ public int hashCode() {
+ int result = (int) (id ^ (id >>> 32));
+ result = 31 * result + (screenName != null ? screenName.hashCode() : 0);
+ result = 31 * result + (name != null ? name.hashCode() : 0);
+ result = 31 * result + (url != null ? url.hashCode() : 0);
+ result = 31 * result + (profileImageUrl != null ? profileImageUrl.hashCode() : 0);
+ result = 31 * result + (description != null ? description.hashCode() : 0);
+ result = 31 * result + (location != null ? location.hashCode() : 0);
+ result = 31 * result + (createdDate != null ? createdDate.hashCode() : 0);
+ result = 31 * result + (language != null ? language.hashCode() : 0);
+ result = 31 * result + statusesCount;
+ result = 31 * result + friendsCount;
+ result = 31 * result + followersCount;
+ result = 31 * result + favoritesCount;
+ result = 31 * result + listedCount;
+ result = 31 * result + (following ? 1 : 0);
+ result = 31 * result + (followRequestSent ? 1 : 0);
+ result = 31 * result + (isProtected ? 1 : 0);
+ result = 31 * result + (notificationsEnabled ? 1 : 0);
+ result = 31 * result + (verified ? 1 : 0);
+ result = 31 * result + (geoEnabled ? 1 : 0);
+ result = 31 * result + (contributorsEnabled ? 1 : 0);
+ result = 31 * result + (translator ? 1 : 0);
+ result = 31 * result + (timeZone != null ? timeZone.hashCode() : 0);
+ result = 31 * result + utcOffset;
+ result = 31 * result + (sidebarBorderColor != null ? sidebarBorderColor.hashCode() : 0);
+ result = 31 * result + (sidebarFillColor != null ? sidebarFillColor.hashCode() : 0);
+ result = 31 * result + (backgroundColor != null ? backgroundColor.hashCode() : 0);
+ result = 31 * result + (useBackgroundImage ? 1 : 0);
+ result = 31 * result + (backgroundImageUrl != null ? backgroundImageUrl.hashCode() : 0);
+ result = 31 * result + (backgroundImageTiled ? 1 : 0);
+ result = 31 * result + (textColor != null ? textColor.hashCode() : 0);
+ result = 31 * result + (linkColor != null ? linkColor.hashCode() : 0);
+ result = 31 * result + (showAllInlineMedia ? 1 : 0);
+ return result;
+ }
- @Override
- public int hashCode()
- {
- int result = (int) (id ^ (id >>> 32));
- result = 31 * result + (screenName != null ? screenName.hashCode() : 0);
- result = 31 * result + (name != null ? name.hashCode() : 0);
- result = 31 * result + (url != null ? url.hashCode() : 0);
- result = 31 * result + (profileImageUrl != null ? profileImageUrl.hashCode() : 0);
- result = 31 * result + (description != null ? description.hashCode() : 0);
- result = 31 * result + (location != null ? location.hashCode() : 0);
- result = 31 * result + (createdDate != null ? createdDate.hashCode() : 0);
- result = 31 * result + (language != null ? language.hashCode() : 0);
- result = 31 * result + statusesCount;
- result = 31 * result + friendsCount;
- result = 31 * result + followersCount;
- result = 31 * result + favoritesCount;
- result = 31 * result + listedCount;
- result = 31 * result + (following ? 1 : 0);
- result = 31 * result + (followRequestSent ? 1 : 0);
- result = 31 * result + (isProtected ? 1 : 0);
- result = 31 * result + (notificationsEnabled ? 1 : 0);
- result = 31 * result + (verified ? 1 : 0);
- result = 31 * result + (geoEnabled ? 1 : 0);
- result = 31 * result + (contributorsEnabled ? 1 : 0);
- result = 31 * result + (translator ? 1 : 0);
- result = 31 * result + (timeZone != null ? timeZone.hashCode() : 0);
- result = 31 * result + utcOffset;
- result = 31 * result + (sidebarBorderColor != null ? sidebarBorderColor.hashCode() : 0);
- result = 31 * result + (sidebarFillColor != null ? sidebarFillColor.hashCode() : 0);
- result = 31 * result + (backgroundColor != null ? backgroundColor.hashCode() : 0);
- result = 31 * result + (useBackgroundImage ? 1 : 0);
- result = 31 * result + (backgroundImageUrl != null ? backgroundImageUrl.hashCode() : 0);
- result = 31 * result + (backgroundImageTiled ? 1 : 0);
- result = 31 * result + (textColor != null ? textColor.hashCode() : 0);
- result = 31 * result + (linkColor != null ? linkColor.hashCode() : 0);
- result = 31 * result + (showAllInlineMedia ? 1 : 0);
- return result;
- }
}
View
192 spring-social-twitter/src/main/java/org/springframework/social/twitter/api/UrlEntity.java
@@ -1,7 +1,20 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.springframework.social.twitter.api;
-import org.codehaus.jackson.annotate.JsonProperty;
-
import java.io.Serializable;
import java.util.Arrays;
@@ -11,102 +24,81 @@
* User: bowen
* Date: 12/26/11
*/
-public class UrlEntity implements Serializable
-{
- private static final long serialVersionUID = 1L;
-
- @JsonProperty("display_url")
- private String display;
-
- @JsonProperty("expanded_url")
- private String expanded;
-
- @JsonProperty("url")
- private String url;
-
- @JsonProperty("indices")
- private int[] indices;
-
-
- /**
- * JSON constructor.
- */
- public UrlEntity()
- {
-
- }
-
-
- public String getDisplayUrl()
- {
- return this.display;
- }
-
-
- public String getExpandedUrl()
- {
- return this.expanded;
- }
-
-
- public String getUrl()
- {
- return this.url;
- }
-
-
- public int[] getIndices()
- {
- if (this.indices == null || this.indices.length <= 0)
- {
- return new int[0];
- }
- return this.indices;
- }
-
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- UrlEntity urlEntity = (UrlEntity) o;
-
- if (display != null ? !display.equals(urlEntity.display) : urlEntity.display != null)
- {
- return false;
- }
- if (expanded != null ? !expanded.equals(urlEntity.expanded) : urlEntity.expanded != null)
- {
- return false;
- }
- if (!Arrays.equals(indices, urlEntity.indices))
- {
- return false;
- }
- if (url != null ? !url.equals(urlEntity.url) : urlEntity.url != null)
- {
- return false;
- }
-
- return true;
- }
-
-
- @Override
- public int hashCode()
- {
- int result = display != null ? display.hashCode() : 0;
- result = 31 * result + (expanded != null ? expanded.hashCode() : 0);
- result = 31 * result + (url != null ? url.hashCode() : 0);
- result = 31 * result + (indices != null ? Arrays.hashCode(indices) : 0);
- return result;
- }
+public class UrlEntity implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ private String display;
+
+ private String expanded;
+
+ private String url;
+
+ private int[] indices;
+
+ public UrlEntity(String display, String expanded, String url, int[] indices) {
+ this.display = display;
+ this.expanded = expanded;
+ this.url = url;
+ this.indices = indices;
+ }
+
+
+ public String getDisplayUrl() {
+ return this.display;
+ }
+
+
+ public String getExpandedUrl() {
+ return this.expanded;
+ }
+
+
+ public String getUrl() {
+ return this.url;
+ }
+
+
+ public int[] getIndices() {
+ if (this.indices == null || this.indices.length <= 0) {
+ return new int[0];
+ }
+ return this.indices;
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ UrlEntity urlEntity = (UrlEntity) o;
+ if (display != null ? !display.equals(urlEntity.display) : urlEntity.display != null) {
+ return false;
+ }
+ if (expanded != null ? !expanded.equals(urlEntity.expanded) : urlEntity.expanded != null) {
+ return false;
+ }
+ if (!Arrays.equals(indices, urlEntity.indices)) {
+ return false;
+ }
+ if (url != null ? !url.equals(urlEntity.url) : urlEntity.url != null) {
+ return false;
+ }
+ return true;
+ }
+
+
+ @Override
+ public int hashCode() {
+ int result = display != null ? display.hashCode() : 0;
+ result = 31 * result + (expanded != null ? expanded.hashCode() : 0);
+ result = 31 * result + (url != null ? url.hashCode() : 0);
+ result = 31 * result + (indices != null ? Arrays.hashCode(indices) : 0);
+ return result;
+ }
}
View
38 ...cial-twitter/src/main/java/org/springframework/social/twitter/api/impl/EntitiesMixin.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.social.twitter.api.impl;
+
+import java.util.List;
+
+import org.codehaus.jackson.annotate.JsonCreator;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.springframework.social.twitter.api.HashTagEntity;
+import org.springframework.social.twitter.api.MediaEntity;
+import org.springframework.social.twitter.api.MentionEntity;
+import org.springframework.social.twitter.api.UrlEntity;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+class EntitiesMixin {
+
+ @JsonCreator
+ public EntitiesMixin(
+ @JsonProperty("urls") List<UrlEntity> urls,
+ @JsonProperty("hashtags") List<HashTagEntity> tags,
+ @JsonProperty("user_mentions") List<MentionEntity> mentions,
+ @JsonProperty("media") List<MediaEntity> media) {}
+
+}
View
30 ...twitter/src/main/java/org/springframework/social/twitter/api/impl/HashTagEntityMixin.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.social.twitter.api.impl;
+
+import org.codehaus.jackson.annotate.JsonCreator;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown=true)
+class HashTagEntityMixin {
+
+ @JsonCreator
+ public HashTagEntityMixin(
+ @JsonProperty("text") String text,
+ @JsonProperty("indices")int[] indices) {}
+
+}
View
2  ...ocial-twitter/src/main/java/org/springframework/social/twitter/api/impl/ListTemplate.java
@@ -95,6 +95,7 @@ public UserList getList(String screenName, String listSlug) {
public List<Tweet> getListStatuses(long listId, int page, int pageSize, long sinceId, long maxId) {
MultiValueMap<String, String> parameters = PagingUtils.buildPagingParametersWithPerPage(page, pageSize, sinceId, maxId);
parameters.set("list_id", String.valueOf(listId));
+ parameters.set("include_entities", "true");
return restTemplate.getForObject(buildUri("lists/statuses.json", parameters), TweetList.class);
}
@@ -110,6 +111,7 @@ public UserList getList(String screenName, String listSlug) {
MultiValueMap<String, String> parameters = PagingUtils.buildPagingParametersWithPerPage(page, pageSize, sinceId, maxId);
parameters.set("owner_screen_name", screenName);
parameters.set("slug", listSlug);
+ parameters.set("include_entities", "true");
return restTemplate.getForObject(buildUri("lists/statuses.json", parameters), TweetList.class);
}
View
36 ...l-twitter/src/main/java/org/springframework/social/twitter/api/impl/MediaEntityMixin.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.social.twitter.api.impl;
+
+import org.codehaus.jackson.annotate.JsonCreator;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+class MediaEntityMixin {
+
+ @JsonCreator
+ public MediaEntityMixin(
+ @JsonProperty("id") long id,
+ @JsonProperty("media_url")String mediaHttp,
+ @JsonProperty("media_url_https")String mediaHttps,
+ @JsonProperty("url")String url,
+ @JsonProperty("display_url")String display,
+ @JsonProperty("expanded_url")String expanded,
+ @JsonProperty("type")String type,
+ @JsonProperty("indices")int[] indices) {}
+
+}
View
32 ...twitter/src/main/java/org/springframework/social/twitter/api/impl/MentionEntityMixin.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.social.twitter.api.impl;
+
+import org.codehaus.jackson.annotate.JsonCreator;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+class MentionEntityMixin {
+
+ @JsonCreator
+ public MentionEntityMixin(
+ @JsonProperty("id") long id,
+ @JsonProperty("screen_name") String screenName,
+ @JsonProperty("name") String name,
+ @JsonProperty("indices") int[] indices) {}
+
+}
View
10 ...ial-twitter/src/main/java/org/springframework/social/twitter/api/impl/SearchTemplate.java
@@ -35,12 +35,9 @@
private final RestTemplate restTemplate;
- private final boolean includeEntities;
-
- public SearchTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser, final boolean includeEntities) {
+ public SearchTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser) {
super(isAuthorizedForUser);
this.restTemplate = restTemplate;
- this.includeEntities = includeEntities;
}
public SearchResults search(String query) {
@@ -65,11 +62,6 @@ public SearchResults search(String query, int page, int resultsPerPage, long sin
searchUrl += "&max_id={max}";
parameters.put("max", String.valueOf(maxId));
}
- if (this.includeEntities)
- {
- searchUrl += "&include_entities={entities}";
- parameters.put("entities", "true");
- }
return restTemplate.getForObject(searchUrl, SearchResults.class, parameters);
}
View
55 ...l-twitter/src/main/java/org/springframework/social/twitter/api/impl/TimelineTemplate.java
<
@@ -35,16 +35,14 @@
private final RestTemplate restTemplate;
- private final boolean includeEntities;
-
- public TimelineTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser, final boolean includeEntities) {
+ public TimelineTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser) {
super(isAuthorizedForUser);
this.restTemplate = restTemplate;
- this.includeEntities = includeEntities;
}
public List<Tweet> getPublicTimeline() {
- MultiValueMap<String, String> parameters = this.buildParameters();
+ MultiValueMap<String, String> parameters = new LinkedMultiValueMap<String, String>();
+ parameters.set("include_entities", "true");
return restTemplate.getForObject(buildUri("statuses/public_timeline.json", parameters), TweetList.class);
}
@@ -59,7 +57,7 @@ public TimelineTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser,
public List<Tweet> getHomeTimeline(int page, int pageSize, long sinceId, long maxId) {
requireAuthorization();
MultiValueMap<String, String> parameters = PagingUtils.buildPagingParametersWithCount(page, pageSize, sinceId, maxId);
- parameters.putAll(this.buildParameters());
+ parameters.set("include_entities", "true");
return restTemplate.getForObject(buildUri("statuses/home_timeline.json", parameters), TweetList.class);
}
@@ -74,7 +72,7 @@ public TimelineTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser,
public List<Tweet> getUserTimeline(int page, int pageSize, long sinceId, long maxId) {
requireAuthorization();
MultiValueMap<String, String> parameters = PagingUtils.buildPagingParametersWithCount(page, pageSize, sinceId, maxId);
- parameters.putAll(this.buildParameters());
+ parameters.set("include_entities", "true");
return restTemplate.getForObject(buildUri("statuses/user_timeline.json", parameters), TweetList.class);
}
@@ -89,7 +87,7 @@ public TimelineTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser,
public List<Tweet> getUserTimeline(String screenName, int page, int pageSize, long sinceId, long maxId) {
MultiValueMap<String, String> parameters = PagingUtils.buildPagingParametersWithCount(page, pageSize, sinceId, maxId);
parameters.set("screen_name", screenName);
- parameters.putAll(this.buildParameters());
+ parameters.set("include_entities", "true");
return restTemplate.getForObject(buildUri("statuses/user_timeline.json", parameters), TweetList.class);
}
@@ -104,7 +102,7 @@ public TimelineTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser,
public List<Tweet> getUserTimeline(long userId, int page, int pageSize, long sinceId, long maxId) {
MultiValueMap<String, String> parameters = PagingUtils.buildPagingParametersWithCount(page, pageSize, sinceId, maxId);
parameters.set("user_id", String.valueOf(userId));
- parameters.putAll(this.buildParameters());
+ parameters.set("include_entities", "true");
return restTemplate.getForObject(buildUri("statuses/user_timeline.json", parameters), TweetList.class);
}
@@ -119,7 +117,7 @@ public TimelineTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser,
public List<Tweet> getMentions(int page, int pageSize, long sinceId, long maxId) {
requireAuthorization();
MultiValueMap<String, String> parameters = PagingUtils.buildPagingParametersWithCount(page, pageSize, sinceId, maxId);
- parameters.putAll(this.buildParameters());
+ parameters.set("include_entities", "true");
return restTemplate.getForObject(buildUri("statuses/mentions.json", parameters), TweetList.class);
}
@@ -134,7 +132,7 @@ public TimelineTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser,
public List<Tweet> getRetweetedByMe(int page, int pageSize, long sinceId, long maxId) {
requireAuthorization();
MultiValueMap<String, String> parameters = PagingUtils.buildPagingParametersWithCount(page, pageSize, sinceId, maxId);
- parameters.putAll(this.buildParameters());
+ parameters.set("include_entities", "true");
return restTemplate.getForObject(buildUri("statuses/retweeted_by_me.json", parameters), TweetList.class);
}
@@ -150,7 +148,7 @@ public TimelineTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser,
requireAuthorization();
MultiValueMap<String, String> parameters = PagingUtils.buildPagingParametersWithCount(page, pageSize, sinceId, maxId);
parameters.set("user_id", String.valueOf(userId));
- parameters.putAll(this.buildParameters());
+ parameters.set("include_entities", "true");
return restTemplate.getForObject(buildUri("statuses/retweeted_by_user.json", parameters), TweetList.class);
}
@@ -166,7 +164,7 @@ public TimelineTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser,
requireAuthorization();
MultiValueMap<String, String> parameters = PagingUtils.buildPagingParametersWithCount(page, pageSize, sinceId, maxId);
parameters.set("screen_name", screenName);
- parameters.putAll(this.buildParameters());
+ parameters.set("include_entities", "true");
return restTemplate.getForObject(buildUri("statuses/retweeted_by_user.json", parameters), TweetList.class);
}
@@ -181,7 +179,7 @@ public TimelineTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser,
public List<Tweet> getRetweetedToMe(int page, int pageSize, long sinceId, long maxId) {
requireAuthorization();
MultiValueMap<String, String> parameters = PagingUtils.buildPagingParametersWithCount(page, pageSize, sinceId, maxId);
- parameters.putAll(this.buildParameters());
+ parameters.set("include_entities", "true");
return restTemplate.getForObject(buildUri("statuses/retweeted_to_me.json", parameters), TweetList.class);
}
@@ -197,7 +195,7 @@ public TimelineTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser,
requireAuthorization();
MultiValueMap<String, String> parameters = PagingUtils.buildPagingParametersWithCount(page, pageSize, sinceId, maxId);
parameters.set("user_id", String.valueOf(userId));
- parameters.putAll(this.buildParameters());
+ parameters.set("include_entities", "true");
return restTemplate.getForObject(buildUri("statuses/retweeted_to_user.json", parameters), TweetList.class);
}
@@ -213,7 +211,7 @@ public TimelineTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser,
requireAuthorization();
MultiValueMap<String, String> parameters = PagingUtils.buildPagingParametersWithCount(page, pageSize, sinceId, maxId);
parameters.set("screen_name", screenName);
- parameters.putAll(this.buildParameters());
+ parameters.set("include_entities", "true");
return restTemplate.getForObject(buildUri("statuses/retweeted_to_user.json", parameters), TweetList.class);
}
@@ -228,12 +226,14 @@ public TimelineTemplate(RestTemplate restTemplate, boolean isAuthorizedForUser,
public List<Tweet> getRetweetsOfMe(int page, int pageSize, long sinceId, long maxId) {
requireAuthorization();
MultiValueMap<String, String> parameters = PagingUtils.buildPagingParametersWithCount(page, pageSize, sinceId, maxId);
- parameters.putAll(this.buildParameters());