fix modernizer warnings

This commit is contained in:
Athou
2014-12-12 10:19:32 +01:00
parent db03dd12a0
commit 56c6e2d29c
16 changed files with 41 additions and 44 deletions

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.cache;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -18,7 +19,6 @@ import com.commafeed.frontend.model.Category;
import com.commafeed.frontend.model.UnreadCount;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.Lists;
@Slf4j
@RequiredArgsConstructor
@@ -30,7 +30,7 @@ public class RedisCacheService extends CacheService {
@Override
public List<String> getLastEntries(Feed feed) {
List<String> list = Lists.newArrayList();
List<String> list = new ArrayList<>();
try (Jedis jedis = pool.getResource()) {
String key = buildRedisEntryKey(feed);
Set<String> members = jedis.smembers(key);

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.dao;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
@@ -27,7 +28,6 @@ import com.commafeed.backend.model.User;
import com.commafeed.backend.model.UserSettings.ReadingOrder;
import com.commafeed.frontend.model.UnreadCount;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
import com.mysema.query.BooleanBuilder;
import com.mysema.query.Tuple;
@@ -216,7 +216,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
List<FeedEntryStatus> placeholders = set.asList();
int size = placeholders.size();
if (size < offset) {
return Lists.newArrayList();
return new ArrayList<>();
}
placeholders = placeholders.subList(Math.max(offset, 0), size);
@@ -224,7 +224,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
if (onlyIds) {
statuses = placeholders;
} else {
statuses = Lists.newArrayList();
statuses = new ArrayList<>();
for (FeedEntryStatus placeholder : placeholders) {
Long statusId = placeholder.getId();
FeedEntry entry = feedEntryDAO.findById(placeholder.getEntry().getId());

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.feed;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
@@ -7,8 +8,6 @@ import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Lists;
/**
* A keyword used in a search query
*/
@@ -24,7 +23,7 @@ public class FeedEntryKeyword {
private final Mode mode;
public static List<FeedEntryKeyword> fromQueryString(String keywords) {
List<FeedEntryKeyword> list = Lists.newArrayList();
List<FeedEntryKeyword> list = new ArrayList<>();
if (keywords != null) {
for (String keyword : StringUtils.split(keywords)) {
boolean not = false;

View File

@@ -1,9 +1,12 @@
package com.commafeed.backend.feed;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import javax.inject.Inject;
import javax.inject.Singleton;
@@ -17,9 +20,6 @@ import com.codahale.metrics.MetricRegistry;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.dao.FeedDAO;
import com.commafeed.backend.model.Feed;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Queues;
@Singleton
public class FeedQueues {
@@ -27,9 +27,9 @@ public class FeedQueues {
private final FeedDAO feedDAO;
private final CommaFeedConfiguration config;
private Queue<FeedRefreshContext> addQueue = Queues.newConcurrentLinkedQueue();
private Queue<FeedRefreshContext> takeQueue = Queues.newConcurrentLinkedQueue();
private Queue<Feed> giveBackQueue = Queues.newConcurrentLinkedQueue();
private Queue<FeedRefreshContext> addQueue = new ConcurrentLinkedQueue<>();
private Queue<FeedRefreshContext> takeQueue = new ConcurrentLinkedQueue<>();
private Queue<Feed> giveBackQueue = new ConcurrentLinkedQueue<>();
private Meter refill;
@@ -97,7 +97,7 @@ public class FeedQueues {
private void refill() {
refill.mark();
List<FeedRefreshContext> contexts = Lists.newArrayList();
List<FeedRefreshContext> contexts = new ArrayList<>();
int batchSize = Math.min(100, 3 * config.getApplicationSettings().getBackgroundThreads());
// add feeds we got from the add() method
@@ -117,7 +117,7 @@ public class FeedQueues {
// set the disabledDate as we use it in feedDAO to decide what to refresh next. We also use a map to remove
// duplicates.
Map<Long, FeedRefreshContext> map = Maps.newLinkedHashMap();
Map<Long, FeedRefreshContext> map = new LinkedHashMap<>();
for (FeedRefreshContext context : contexts) {
Feed feed = context.getFeed();
feed.setDisabledUntil(DateUtils.addMinutes(new Date(), config.getApplicationSettings().getRefreshIntervalMinutes()));
@@ -135,7 +135,7 @@ public class FeedQueues {
}
// update all feeds in the database
List<Feed> feeds = Lists.newArrayList();
List<Feed> feeds = new ArrayList<>();
for (FeedRefreshContext context : map.values()) {
feeds.add(context.getFeed());
}

View File

@@ -2,6 +2,7 @@ package com.commafeed.backend.feed;
import io.dropwizard.lifecycle.Managed;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Iterator;
@@ -36,7 +37,6 @@ import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.backend.model.User;
import com.commafeed.backend.service.FeedUpdateService;
import com.commafeed.backend.service.PubSubService;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.Striped;
@Slf4j
@@ -113,7 +113,7 @@ public class FeedRefreshUpdater implements Managed {
feed.setMessage("Feed has no entries");
} else {
List<String> lastEntries = cache.getLastEntries(feed);
List<String> currentEntries = Lists.newArrayList();
List<String> currentEntries = new ArrayList<>();
List<FeedSubscription> subscriptions = null;
for (FeedEntry entry : entries) {

View File

@@ -4,6 +4,7 @@ import java.io.StringReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
@@ -34,7 +35,6 @@ import com.commafeed.backend.feed.FeedEntryKeyword.Mode;
import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.frontend.model.Entry;
import com.google.common.collect.Lists;
import com.ibm.icu.text.CharsetDetector;
import com.ibm.icu.text.CharsetMatch;
import com.steadystate.css.parser.CSSOMParser;
@@ -231,7 +231,7 @@ public class FeedUtils {
String rule = "";
CSSOMParser parser = new CSSOMParser();
try {
List<String> rules = Lists.newArrayList();
List<String> rules = new ArrayList<>();
CSSStyleDeclaration decl = parser.parseStyleDeclaration(new InputSource(new StringReader(orig)));
for (int i = 0; i < decl.getLength(); i++) {
@@ -256,7 +256,7 @@ public class FeedUtils {
String rule = "";
CSSOMParser parser = new CSSOMParser();
try {
List<String> rules = Lists.newArrayList();
List<String> rules = new ArrayList<>();
CSSStyleDeclaration decl = parser.parseStyleDeclaration(new InputSource(new StringReader(orig)));
for (int i = 0; i < decl.getLength(); i++) {

View File

@@ -1,15 +1,14 @@
package com.commafeed.backend.feed;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import com.google.common.collect.Maps;
public class HtmlEntities {
public static final Map<String, String> NUMERIC_MAPPING = Collections.unmodifiableMap(loadMap());
private static synchronized Map<String, String> loadMap() {
Map<String, String> map = Maps.newLinkedHashMap();
Map<String, String> map = new LinkedHashMap<>();
map.put("&Aacute;", "&#193;");
map.put("&aacute;", "&#225;");
map.put("&Acirc;", "&#194;");

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.model;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -16,8 +17,6 @@ import javax.persistence.Transient;
import lombok.Getter;
import lombok.Setter;
import com.google.common.collect.Lists;
@Entity
@Table(name = "FEEDENTRYSTATUSES")
@SuppressWarnings("serial")
@@ -41,7 +40,7 @@ public class FeedEntryStatus extends AbstractModel {
private boolean markable;
@Transient
private List<FeedEntryTag> tags = Lists.newArrayList();
private List<FeedEntryTag> tags = new ArrayList<>();
/**
* Denormalization starts here

View File

@@ -1,6 +1,7 @@
package com.commafeed.backend.model;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
@@ -19,7 +20,6 @@ import org.apache.commons.lang3.time.DateUtils;
import org.hibernate.annotations.Cascade;
import com.commafeed.backend.model.UserRole.Role;
import com.google.common.collect.Sets;
@Entity
@Table(name = "USERS")
@@ -61,7 +61,7 @@ public class User extends AbstractModel {
@OneToMany(mappedBy = "user", cascade = { CascadeType.PERSIST, CascadeType.REMOVE })
@Cascade({ org.hibernate.annotations.CascadeType.PERSIST, org.hibernate.annotations.CascadeType.SAVE_UPDATE,
org.hibernate.annotations.CascadeType.REMOVE })
private Set<UserRole> roles = Sets.newHashSet();
private Set<UserRole> roles = new HashSet<>();
@OneToMany(mappedBy = "user", fetch = FetchType.LAZY, cascade = CascadeType.REMOVE)
private Set<FeedSubscription> subscriptions;

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -17,7 +18,6 @@ import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.FeedEntryStatus;
import com.commafeed.backend.model.FeedSubscription;
import com.commafeed.backend.model.User;
import com.google.common.collect.Lists;
@RequiredArgsConstructor(onConstructor = @__({ @Inject }))
@Singleton
@@ -80,7 +80,7 @@ public class FeedEntryService {
}
private void markList(List<FeedEntryStatus> statuses, Date olderThan) {
List<FeedEntryStatus> list = Lists.newArrayList();
List<FeedEntryStatus> list = new ArrayList<>();
for (FeedEntryStatus status : statuses) {
if (!status.isRead()) {
Date inserted = status.getEntry().getInserted();

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.service;
import java.util.ArrayList;
import java.util.List;
import javax.inject.Inject;
@@ -26,7 +27,6 @@ import com.commafeed.backend.feed.FeedQueues;
import com.commafeed.backend.feed.FeedUtils;
import com.commafeed.backend.model.Feed;
import com.commafeed.frontend.resource.PubSubHubbubCallbackREST;
import com.google.common.collect.Lists;
/**
* Sends push subscription requests. Callback is handled by {@link PubSubHubbubCallbackREST}
@@ -57,7 +57,7 @@ public class PubSubService {
log.debug("sending new pubsub subscription to {} for {}", hub, topic);
HttpPost post = new HttpPost(hub);
List<NameValuePair> nvp = Lists.newArrayList();
List<NameValuePair> nvp = new ArrayList<>();
nvp.add(new BasicNameValuePair("hub.callback", publicUrl + "/rest/push/callback"));
nvp.add(new BasicNameValuePair("hub.topic", topic));
nvp.add(new BasicNameValuePair("hub.mode", "subscribe"));

View File

@@ -1,11 +1,11 @@
package com.commafeed.frontend.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import com.google.common.collect.Lists;
import com.wordnik.swagger.annotations.ApiModel;
import com.wordnik.swagger.annotations.ApiModelProperty;
@@ -24,10 +24,10 @@ public class Category implements Serializable {
private String name;
@ApiModelProperty("category children categories")
private List<Category> children = Lists.newArrayList();
private List<Category> children = new ArrayList<>();
@ApiModelProperty("category feeds")
private List<Subscription> feeds = Lists.newArrayList();
private List<Subscription> feeds = new ArrayList<>();
@ApiModelProperty("wether the category is expanded or collapsed")
private boolean expanded;

View File

@@ -1,11 +1,11 @@
package com.commafeed.frontend.model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
import com.google.common.collect.Lists;
import com.wordnik.swagger.annotations.ApiModel;
import com.wordnik.swagger.annotations.ApiModelProperty;
@@ -39,7 +39,7 @@ public class Entries implements Serializable {
private int limit;
@ApiModelProperty("list of entries")
private List<Entry> entries = Lists.newArrayList();
private List<Entry> entries = new ArrayList<>();
@ApiModelProperty("if true, the unread flag was ignored in the request, all entries are returned regardless of their read status")
private boolean ignoredReadStatus;

View File

@@ -2,6 +2,7 @@ package com.commafeed.frontend.resource;
import io.dropwizard.hibernate.UnitOfWork;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -36,7 +37,6 @@ import com.commafeed.frontend.auth.SecurityCheck;
import com.commafeed.frontend.model.UserModel;
import com.commafeed.frontend.model.request.IDRequest;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
@@ -136,7 +136,7 @@ public class AdminREST {
@UnitOfWork
@ApiOperation(value = "Get all users", notes = "Get all users", response = UserModel.class, responseContainer = "List")
public Response getUsers(@SecurityCheck(Role.ADMIN) User user) {
Map<Long, UserModel> users = Maps.newHashMap();
Map<Long, UserModel> users = new HashMap<>();
for (UserRole role : userRoleDAO.findAll()) {
User u = role.getUser();
Long key = u.getId();

View File

@@ -11,6 +11,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import javax.inject.Inject;
@@ -59,7 +60,6 @@ import com.commafeed.frontend.model.request.CategoryModificationRequest;
import com.commafeed.frontend.model.request.CollapseRequest;
import com.commafeed.frontend.model.request.IDRequest;
import com.commafeed.frontend.model.request.MarkRequest;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.rometools.rome.feed.synd.SyndFeed;
@@ -132,7 +132,7 @@ public class CategoryREST {
}
if (ALL.equals(id)) {
entries.setName(Optional.fromNullable(tag).or("All"));
entries.setName(Optional.ofNullable(tag).orElse("All"));
List<FeedSubscription> subs = feedSubscriptionDAO.findAll(user);
removeExcludedSubscriptions(subs, excludedIds);
List<FeedEntryStatus> list = feedEntryStatusDAO.findBySubscriptions(user, subs, unreadOnly, entryKeywords, newerThanDate,

View File

@@ -168,7 +168,7 @@ public class URLCanonicalizer {
return "";
}
final StringBuffer sb = new StringBuffer(100);
final StringBuilder sb = new StringBuilder(100);
for (Map.Entry<String, String> pair : sortedParamMap.entrySet()) {
final String key = pair.getKey().toLowerCase();
if (key.equals("jsessionid") || key.equals("phpsessid") || key.equals("aspsessionid")) {