intellij autofixes

This commit is contained in:
Athou
2023-05-31 07:27:24 +02:00
parent f5c0e2d375
commit bb25e0ede6
26 changed files with 39 additions and 41 deletions

View File

@@ -12,7 +12,7 @@ import java.util.List;
*/ */
public class FixedSizeSortedSet<E> { public class FixedSizeSortedSet<E> {
private List<E> inner; private final List<E> inner;
private final Comparator<? super E> comparator; private final Comparator<? super E> comparator;
private final int capacity; private final int capacity;

View File

@@ -18,7 +18,7 @@ import com.querydsl.core.types.Predicate;
@Singleton @Singleton
public class FeedCategoryDAO extends GenericDAO<FeedCategory> { public class FeedCategoryDAO extends GenericDAO<FeedCategory> {
private QFeedCategory category = QFeedCategory.feedCategory; private final QFeedCategory category = QFeedCategory.feedCategory;
@Inject @Inject
public FeedCategoryDAO(SessionFactory sessionFactory) { public FeedCategoryDAO(SessionFactory sessionFactory) {

View File

@@ -21,7 +21,7 @@ import lombok.Getter;
@Singleton @Singleton
public class FeedEntryDAO extends GenericDAO<FeedEntry> { public class FeedEntryDAO extends GenericDAO<FeedEntry> {
private QFeedEntry entry = QFeedEntry.feedEntry; private final QFeedEntry entry = QFeedEntry.feedEntry;
@Inject @Inject
public FeedEntryDAO(SessionFactory sessionFactory) { public FeedEntryDAO(SessionFactory sessionFactory) {

View File

@@ -77,7 +77,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
private FeedEntryStatus handleStatus(User user, FeedEntryStatus status, FeedSubscription sub, FeedEntry entry) { private FeedEntryStatus handleStatus(User user, FeedEntryStatus status, FeedSubscription sub, FeedEntry entry) {
if (status == null) { if (status == null) {
Date unreadThreshold = config.getApplicationSettings().getUnreadThreshold(); Date unreadThreshold = config.getApplicationSettings().getUnreadThreshold();
boolean read = unreadThreshold == null ? false : entry.getUpdated().before(unreadThreshold); boolean read = unreadThreshold != null && entry.getUpdated().before(unreadThreshold);
status = new FeedEntryStatus(user, sub, entry); status = new FeedEntryStatus(user, sub, entry);
status.setRead(read); status.setRead(read);
status.setMarkable(!read); status.setMarkable(!read);

View File

@@ -15,7 +15,7 @@ import com.commafeed.backend.model.User;
@Singleton @Singleton
public class FeedEntryTagDAO extends GenericDAO<FeedEntryTag> { public class FeedEntryTagDAO extends GenericDAO<FeedEntryTag> {
private QFeedEntryTag tag = QFeedEntryTag.feedEntryTag; private final QFeedEntryTag tag = QFeedEntryTag.feedEntryTag;
@Inject @Inject
public FeedEntryTagDAO(SessionFactory sessionFactory) { public FeedEntryTagDAO(SessionFactory sessionFactory) {

View File

@@ -21,7 +21,7 @@ import com.querydsl.jpa.JPQLQuery;
@Singleton @Singleton
public class FeedSubscriptionDAO extends GenericDAO<FeedSubscription> { public class FeedSubscriptionDAO extends GenericDAO<FeedSubscription> {
private QFeedSubscription sub = QFeedSubscription.feedSubscription; private final QFeedSubscription sub = QFeedSubscription.feedSubscription;
@Inject @Inject
public FeedSubscriptionDAO(SessionFactory sessionFactory) { public FeedSubscriptionDAO(SessionFactory sessionFactory) {

View File

@@ -15,7 +15,7 @@ import io.dropwizard.hibernate.AbstractDAO;
public abstract class GenericDAO<T extends AbstractModel> extends AbstractDAO<T> { public abstract class GenericDAO<T extends AbstractModel> extends AbstractDAO<T> {
private JPAQueryFactory factory; private final JPAQueryFactory factory;
protected GenericDAO(SessionFactory sessionFactory) { protected GenericDAO(SessionFactory sessionFactory) {
super(sessionFactory); super(sessionFactory);

View File

@@ -11,7 +11,7 @@ import com.commafeed.backend.model.User;
@Singleton @Singleton
public class UserDAO extends GenericDAO<User> { public class UserDAO extends GenericDAO<User> {
private QUser user = QUser.user; private final QUser user = QUser.user;
@Inject @Inject
public UserDAO(SessionFactory sessionFactory) { public UserDAO(SessionFactory sessionFactory) {

View File

@@ -17,7 +17,7 @@ import com.commafeed.backend.model.UserRole.Role;
@Singleton @Singleton
public class UserRoleDAO extends GenericDAO<UserRole> { public class UserRoleDAO extends GenericDAO<UserRole> {
private QUserRole role = QUserRole.userRole; private final QUserRole role = QUserRole.userRole;
@Inject @Inject
public UserRoleDAO(SessionFactory sessionFactory) { public UserRoleDAO(SessionFactory sessionFactory) {

View File

@@ -12,7 +12,7 @@ import com.commafeed.backend.model.UserSettings;
@Singleton @Singleton
public class UserSettingsDAO extends GenericDAO<UserSettings> { public class UserSettingsDAO extends GenericDAO<UserSettings> {
private QUserSettings settings = QUserSettings.userSettings; private final QUserSettings settings = QUserSettings.userSettings;
@Inject @Inject
public UserSettingsDAO(SessionFactory sessionFactory) { public UserSettingsDAO(SessionFactory sessionFactory) {

View File

@@ -16,7 +16,7 @@ import lombok.RequiredArgsConstructor;
public class FeedEntryKeyword { public class FeedEntryKeyword {
public enum Mode { public enum Mode {
INCLUDE, EXCLUDE; INCLUDE, EXCLUDE
} }
private final String keyword; private final String keyword;

View File

@@ -73,7 +73,7 @@ public class FeedFetcher {
boolean etagHeaderValueChanged = !StringUtils.equals(eTag, result.getETag()); boolean etagHeaderValueChanged = !StringUtils.equals(eTag, result.getETag());
String hash = DigestUtils.sha1Hex(content); String hash = DigestUtils.sha1Hex(content);
if (lastContentHash != null && hash != null && lastContentHash.equals(hash)) { if (lastContentHash != null && lastContentHash.equals(hash)) {
log.debug("content hash not modified: {}", feedUrl); log.debug("content hash not modified: {}", feedUrl);
throw new NotModifiedException("content hash not modified", throw new NotModifiedException("content hash not modified",
lastModifiedHeaderValueChanged ? result.getLastModifiedSince() : null, lastModifiedHeaderValueChanged ? result.getLastModifiedSince() : null,

View File

@@ -13,8 +13,8 @@ import com.commafeed.backend.model.Feed;
@Singleton @Singleton
public class FeedRefreshIntervalCalculator { public class FeedRefreshIntervalCalculator {
private boolean heavyLoad; private final boolean heavyLoad;
private int refreshIntervalMinutes; private final int refreshIntervalMinutes;
@Inject @Inject
public FeedRefreshIntervalCalculator(CommaFeedConfiguration config) { public FeedRefreshIntervalCalculator(CommaFeedConfiguration config) {

View File

@@ -88,7 +88,7 @@ public class FeedRefreshUpdater implements Managed {
// lock on feed, make sure we are not updating the same feed twice at // lock on feed, make sure we are not updating the same feed twice at
// the same time // the same time
String key1 = StringUtils.trimToEmpty("" + feed.getId()); String key1 = StringUtils.trimToEmpty(String.valueOf(feed.getId()));
// lock on content, make sure we are not updating the same entry // lock on content, make sure we are not updating the same entry
// twice at the same time // twice at the same time

View File

@@ -154,7 +154,7 @@ public class FeedUtils {
for (Emit emit : emits) { for (Emit emit : emits) {
int matchIndex = emit.getStart(); int matchIndex = emit.getStart();
sb.append(source.substring(prevIndex, matchIndex)); sb.append(source, prevIndex, matchIndex);
sb.append(HtmlEntities.HTML_TO_NUMERIC_MAP.get(emit.getKeyword())); sb.append(HtmlEntities.HTML_TO_NUMERIC_MAP.get(emit.getKeyword()));
prevIndex = emit.getEnd() + 1; prevIndex = emit.getEnd() + 1;
} }
@@ -228,7 +228,7 @@ public class FeedUtils {
if (index == -1) { if (index == -1) {
return null; return null;
} }
String encoding = pi.substring(index + 10, pi.length()); String encoding = pi.substring(index + 10);
encoding = encoding.substring(0, encoding.indexOf('"')); encoding = encoding.substring(0, encoding.indexOf('"'));
return encoding; return encoding;
} }

View File

@@ -23,11 +23,7 @@ public class OPML11Parser extends OPML10Parser {
public boolean isMyType(Document document) { public boolean isMyType(Document document) {
Element e = document.getRootElement(); Element e = document.getRootElement();
if (e.getName().equals("opml")) { return e.getName().equals("opml");
return true;
}
return false;
} }

View File

@@ -22,7 +22,7 @@ public class FeedService {
private final FeedDAO feedDAO; private final FeedDAO feedDAO;
private final Set<AbstractFaviconFetcher> faviconFetchers; private final Set<AbstractFaviconFetcher> faviconFetchers;
private Favicon defaultFavicon; private final Favicon defaultFavicon;
@Inject @Inject
public FeedService(FeedDAO feedDAO, Set<AbstractFaviconFetcher> faviconFetchers) { public FeedService(FeedDAO feedDAO, Set<AbstractFaviconFetcher> faviconFetchers) {

View File

@@ -41,9 +41,9 @@ public class MailService {
Properties props = new Properties(); Properties props = new Properties();
props.put("mail.smtp.auth", "true"); props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "" + settings.isSmtpTls()); props.put("mail.smtp.starttls.enable", String.valueOf(settings.isSmtpTls()));
props.put("mail.smtp.host", settings.getSmtpHost()); props.put("mail.smtp.host", settings.getSmtpHost());
props.put("mail.smtp.port", "" + settings.getSmtpPort()); props.put("mail.smtp.port", String.valueOf(settings.getSmtpPort()));
Session session = Session.getInstance(props, new Authenticator() { Session session = Session.getInstance(props, new Authenticator() {
@Override @Override

View File

@@ -2,6 +2,7 @@ package com.commafeed.backend.service;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
@@ -123,7 +124,7 @@ public class UserService {
} }
public void createDemoUser() { public void createDemoUser() {
register(CommaFeedApplication.USERNAME_DEMO, "demo", "demo@commafeed.com", Arrays.asList(Role.USER), true); register(CommaFeedApplication.USERNAME_DEMO, "demo", "demo@commafeed.com", Collections.singletonList(Role.USER), true);
} }
public void unregister(User user) { public void unregister(User user) {

View File

@@ -21,8 +21,8 @@ import lombok.RequiredArgsConstructor;
@Singleton @Singleton
public class SecurityCheckFactoryProvider extends AbstractValueParamProvider { public class SecurityCheckFactoryProvider extends AbstractValueParamProvider {
private UserService userService; private final UserService userService;
private HttpServletRequest request; private final HttpServletRequest request;
@Inject @Inject
public SecurityCheckFactoryProvider(final MultivaluedParameterExtractorProvider extractorProvider, UserService userService, public SecurityCheckFactoryProvider(final MultivaluedParameterExtractorProvider extractorProvider, UserService userService,

View File

@@ -1,7 +1,7 @@
package com.commafeed.frontend.model; package com.commafeed.frontend.model;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -158,13 +158,13 @@ public class Entry implements Serializable {
SyndContentImpl content = new SyndContentImpl(); SyndContentImpl content = new SyndContentImpl();
content.setValue(getContent()); content.setValue(getContent());
entry.setContents(Arrays.<SyndContent> asList(content)); entry.setContents(Collections.<SyndContent> singletonList(content));
if (getEnclosureUrl() != null) { if (getEnclosureUrl() != null) {
SyndEnclosureImpl enclosure = new SyndEnclosureImpl(); SyndEnclosureImpl enclosure = new SyndEnclosureImpl();
enclosure.setType(getEnclosureType()); enclosure.setType(getEnclosureType());
enclosure.setUrl(getEnclosureUrl()); enclosure.setUrl(getEnclosureUrl());
entry.setEnclosures(Arrays.<SyndEnclosure> asList(enclosure)); entry.setEnclosures(Collections.<SyndEnclosure> singletonList(enclosure));
} }
entry.setLink(getUrl()); entry.setLink(getUrl());

View File

@@ -3,7 +3,7 @@ package com.commafeed.frontend.resource;
import java.io.InputStream; import java.io.InputStream;
import java.io.StringWriter; import java.io.StringWriter;
import java.net.URI; import java.net.URI;
import java.util.Arrays; import java.nio.charset.StandardCharsets;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
@@ -171,7 +171,7 @@ public class FeedREST {
entries.setErrorCount(subscription.getFeed().getErrorCount()); entries.setErrorCount(subscription.getFeed().getErrorCount());
entries.setFeedLink(subscription.getFeed().getLink()); entries.setFeedLink(subscription.getFeed().getLink());
List<FeedEntryStatus> list = feedEntryStatusDAO.findBySubscriptions(user, Arrays.asList(subscription), unreadOnly, List<FeedEntryStatus> list = feedEntryStatusDAO.findBySubscriptions(user, Collections.singletonList(subscription), unreadOnly,
entryKeywords, newerThanDate, offset, limit + 1, order, true, onlyIds, null); entryKeywords, newerThanDate, offset, limit + 1, order, true, onlyIds, null);
for (FeedEntryStatus status : list) { for (FeedEntryStatus status : list) {
@@ -323,7 +323,7 @@ public class FeedREST {
FeedSubscription subscription = feedSubscriptionDAO.findById(user, Long.valueOf(req.getId())); FeedSubscription subscription = feedSubscriptionDAO.findById(user, Long.valueOf(req.getId()));
if (subscription != null) { if (subscription != null) {
feedEntryService.markSubscriptionEntries(user, Arrays.asList(subscription), olderThan, entryKeywords); feedEntryService.markSubscriptionEntries(user, Collections.singletonList(subscription), olderThan, entryKeywords);
} }
return Response.ok().build(); return Response.ok().build();
} }
@@ -522,7 +522,7 @@ public class FeedREST {
return Response.status(Status.FORBIDDEN).entity("Import is disabled for the demo account").build(); return Response.status(Status.FORBIDDEN).entity("Import is disabled for the demo account").build();
} }
try { try {
String opml = IOUtils.toString(input, "UTF-8"); String opml = IOUtils.toString(input, StandardCharsets.UTF_8);
opmlImporter.importOpml(user, opml); opmlImporter.importOpml(user, opml);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);

View File

@@ -1,6 +1,6 @@
package com.commafeed.frontend.resource; package com.commafeed.frontend.resource;
import java.util.Arrays; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
@@ -227,7 +227,8 @@ public class UserREST {
public Response registerUser(@Valid @ApiParam(required = true) RegistrationRequest req, public Response registerUser(@Valid @ApiParam(required = true) RegistrationRequest req,
@Context @ApiParam(hidden = true) SessionHelper sessionHelper) { @Context @ApiParam(hidden = true) SessionHelper sessionHelper) {
try { try {
User registeredUser = userService.register(req.getName(), req.getPassword(), req.getEmail(), Arrays.asList(Role.USER)); User registeredUser = userService.register(req.getName(), req.getPassword(), req.getEmail(),
Collections.singletonList(Role.USER));
userService.login(req.getName(), req.getPassword()); userService.login(req.getName(), req.getPassword());
sessionHelper.setLoggedInUser(registeredUser); sessionHelper.setLoggedInUser(registeredUser);
return Response.ok().build(); return Response.ok().build();

View File

@@ -17,7 +17,7 @@ import org.glassfish.jersey.server.spi.internal.ValueParamProvider;
@Singleton @Singleton
public class SessionHelperFactoryProvider extends AbstractValueParamProvider { public class SessionHelperFactoryProvider extends AbstractValueParamProvider {
private HttpServletRequest request; private final HttpServletRequest request;
@Inject @Inject
public SessionHelperFactoryProvider(final MultivaluedParameterExtractorProvider extractorProvider, HttpServletRequest request) { public SessionHelperFactoryProvider(final MultivaluedParameterExtractorProvider extractorProvider, HttpServletRequest request) {

View File

@@ -7,7 +7,7 @@ import lombok.experimental.UtilityClass;
@UtilityClass @UtilityClass
public class WebSocketMessageBuilder { public class WebSocketMessageBuilder {
public static final String newFeedEntries(FeedSubscription subscription) { public static String newFeedEntries(FeedSubscription subscription) {
return String.format("%s:%s", "new-feed-entries", subscription.getId()); return String.format("%s:%s", "new-feed-entries", subscription.getId());
} }

View File

@@ -1,6 +1,6 @@
package com.commafeed.frontend.resource; package com.commafeed.frontend.resource;
import java.util.Arrays; import java.util.Collections;
import java.util.Optional; import java.util.Optional;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
@@ -76,7 +76,7 @@ class UserRestTest {
userREST.registerUser(req, sessionHelper); userREST.registerUser(req, sessionHelper);
inOrder.verify(service).register("user", "password", "test@test.com", Arrays.asList(Role.USER)); inOrder.verify(service).register("user", "password", "test@test.com", Collections.singletonList(Role.USER));
inOrder.verify(service).login("user", "password"); inOrder.verify(service).login("user", "password");
} }