From 2bacfa78f3191fd9847574a6c8b218a4882844a4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 22 Feb 2019 23:49:12 +0100 Subject: [PATCH] Replace unnecessary type parameters with <> --- .../sone/core/ConfigurationSoneParser.java | 16 ++++++------- .../java/net/pterodactylus/sone/core/Core.java | 14 ++++++------ .../pterodactylus/sone/core/FreenetInterface.java | 2 +- .../net/pterodactylus/sone/core/Preferences.java | 22 +++++++++--------- .../sone/core/SoneDownloaderImpl.java | 2 +- .../net/pterodactylus/sone/core/SoneInserter.java | 12 +++++----- .../net/pterodactylus/sone/core/SoneParser.java | 12 +++++----- .../sone/core/WebOfTrustUpdaterImpl.java | 2 +- .../java/net/pterodactylus/sone/data/Album.java | 2 +- .../java/net/pterodactylus/sone/data/Profile.java | 2 +- .../pterodactylus/sone/data/impl/AlbumImpl.java | 10 ++++----- .../net/pterodactylus/sone/data/impl/SoneImpl.java | 16 ++++++------- .../sone/database/memory/ConfigurationLoader.java | 2 +- .../database/memory/MemoryBookmarkDatabase.java | 2 +- .../net/pterodactylus/sone/fcp/FcpInterface.java | 2 +- .../pterodactylus/sone/fcp/GetPostFeedCommand.java | 4 ++-- .../pterodactylus/sone/fcp/GetSonesCommand.java | 2 +- .../net/pterodactylus/sone/freenet/L10nFilter.java | 2 +- .../sone/freenet/wot/IdentityLoader.java | 2 +- .../sone/freenet/wot/IdentityManagerImpl.java | 4 ++-- .../sone/freenet/wot/WebOfTrustConnector.java | 8 +++---- .../net/pterodactylus/sone/main/DebugLoaders.java | 2 +- .../sone/notify/ListNotification.java | 4 ++-- .../sone/notify/ListNotificationFilter.java | 6 ++--- .../pterodactylus/sone/template/AlbumAccessor.java | 2 +- .../sone/template/CollectionAccessor.java | 2 +- .../sone/template/FilesystemTemplate.java | 4 ++-- .../sone/template/RequestChangeFilter.java | 2 +- .../sone/template/UniqueElementFilter.java | 2 +- .../net/pterodactylus/sone/web/WebInterface.java | 26 +++++++++++----------- .../pterodactylus/sone/web/page/PageToadlet.java | 2 +- .../sone/core/FreenetInterfaceTest.java | 2 +- .../pterodactylus/sone/core/SoneInserterTest.java | 6 ++--- .../pterodactylus/sone/core/SoneParserTest.java | 8 +++---- .../memory/MemoryBookmarkDatabaseTest.java | 6 ++--- .../sone/database/memory/MemoryDatabaseTest.java | 2 +- .../freenet/wot/IdentityChangeEventSenderTest.java | 4 ++-- .../sone/notify/ListNotificationTest.java | 2 +- .../sone/template/CollectionAccessorTest.java | 2 +- .../sone/template/FilesystemTemplateTest.java | 2 +- .../sone/template/GetPagePluginTest.java | 2 +- .../pterodactylus/sone/test/TestAlbumBuilder.java | 4 ++-- .../net/pterodactylus/sone/test/TestValue.java | 4 ++-- .../sone/utils/DefaultOptionTest.java | 18 +++++++-------- 44 files changed, 127 insertions(+), 127 deletions(-) diff --git a/src/main/java/net/pterodactylus/sone/core/ConfigurationSoneParser.java b/src/main/java/net/pterodactylus/sone/core/ConfigurationSoneParser.java index aa387e9..99c1c9d 100644 --- a/src/main/java/net/pterodactylus/sone/core/ConfigurationSoneParser.java +++ b/src/main/java/net/pterodactylus/sone/core/ConfigurationSoneParser.java @@ -33,9 +33,9 @@ public class ConfigurationSoneParser { private final Configuration configuration; private final Sone sone; private final String sonePrefix; - private final Map albums = new HashMap(); - private final List topLevelAlbums = new ArrayList(); - private final Map images = new HashMap(); + private final Map albums = new HashMap<>(); + private final List topLevelAlbums = new ArrayList<>(); + private final Map images = new HashMap<>(); public ConfigurationSoneParser(Configuration configuration, Sone sone) { this.configuration = configuration; @@ -84,7 +84,7 @@ public class ConfigurationSoneParser { public Set parsePosts(PostBuilderFactory postBuilderFactory) throws InvalidPostFound { - Set posts = new HashSet(); + Set posts = new HashSet<>(); while (true) { String postPrefix = "/Posts/" + posts.size(); String postId = getString(postPrefix + "/ID", null); @@ -121,7 +121,7 @@ public class ConfigurationSoneParser { public Set parsePostReplies( PostReplyBuilderFactory postReplyBuilderFactory) { - Set replies = new HashSet(); + Set replies = new HashSet<>(); while (true) { String replyPrefix = "/Replies/" + replies.size(); String replyId = getString(replyPrefix + "/ID", null); @@ -147,7 +147,7 @@ public class ConfigurationSoneParser { } public Set parseLikedPostIds() { - Set likedPostIds = new HashSet(); + Set likedPostIds = new HashSet<>(); while (true) { String likedPostId = getString("/Likes/Post/" + likedPostIds.size() + "/ID", @@ -161,7 +161,7 @@ public class ConfigurationSoneParser { } public Set parseLikedPostReplyIds() { - Set likedPostReplyIds = new HashSet(); + Set likedPostReplyIds = new HashSet<>(); while (true) { String likedReplyId = getString( "/Likes/Reply/" + likedPostReplyIds.size() + "/ID", null); @@ -174,7 +174,7 @@ public class ConfigurationSoneParser { } public Set parseFriends() { - Set friends = new HashSet(); + Set friends = new HashSet<>(); while (true) { String friendId = getString("/Friends/" + friends.size() + "/ID", null); diff --git a/src/main/java/net/pterodactylus/sone/core/Core.java b/src/main/java/net/pterodactylus/sone/core/Core.java index 8e20176..8c05fe4 100644 --- a/src/main/java/net/pterodactylus/sone/core/Core.java +++ b/src/main/java/net/pterodactylus/sone/core/Core.java @@ -156,18 +156,18 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, /** Locked local Sones. */ /* synchronize on itself. */ - private final Set lockedSones = new HashSet(); + private final Set lockedSones = new HashSet<>(); /** Sone inserters. */ /* synchronize access on this on sones. */ - private final Map soneInserters = new HashMap(); + private final Map soneInserters = new HashMap<>(); /** Sone rescuers. */ /* synchronize access on this on sones. */ - private final Map soneRescuers = new HashMap(); + private final Map soneRescuers = new HashMap<>(); /** All known Sones. */ - private final Set knownSones = new HashSet(); + private final Set knownSones = new HashSet<>(); /** The post database. */ private final Database database; @@ -176,7 +176,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, private final Multimap trustedIdentities = Multimaps.synchronizedSetMultimap(HashMultimap.create()); /** All temporary images. */ - private final Map temporaryImages = new HashMap(); + private final Map temporaryImages = new HashMap<>(); /** Ticker for threads that mark own elements as known. */ private final ScheduledExecutorService localElementTicker = Executors.newScheduledThreadPool(1); @@ -444,7 +444,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, * @return The Sones that like the given post */ public Set getLikes(Post post) { - Set sones = new HashSet(); + Set sones = new HashSet<>(); for (Sone sone : getSones()) { if (sone.getLikedPostIds().contains(post.getId())) { sones.add(sone); @@ -461,7 +461,7 @@ public class Core extends AbstractService implements SoneProvider, PostProvider, * @return The Sones that like the given reply */ public Set getLikes(PostReply reply) { - Set sones = new HashSet(); + Set sones = new HashSet<>(); for (Sone sone : getSones()) { if (sone.getLikedReplyIds().contains(reply.getId())) { sones.add(sone); diff --git a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java index f2cbec6..b2ac0ce 100644 --- a/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java +++ b/src/main/java/net/pterodactylus/sone/core/FreenetInterface.java @@ -96,7 +96,7 @@ public class FreenetInterface { private final RequestClient requestClient = new RequestClientBuilder().realTime().build(); /** The USK callbacks. */ - private final Map soneUskCallbacks = new HashMap(); + private final Map soneUskCallbacks = new HashMap<>(); /** The not-Sone-related USK callbacks. */ private final Map uriUskCallbacks = Collections.synchronizedMap(new HashMap()); diff --git a/src/main/java/net/pterodactylus/sone/core/Preferences.java b/src/main/java/net/pterodactylus/sone/core/Preferences.java index 73d964c..bd3c056 100644 --- a/src/main/java/net/pterodactylus/sone/core/Preferences.java +++ b/src/main/java/net/pterodactylus/sone/core/Preferences.java @@ -44,28 +44,28 @@ public class Preferences { private final EventBus eventBus; private final Option insertionDelay = - new DefaultOption(60, range(0, MAX_VALUE)); + new DefaultOption<>(60, range(0, MAX_VALUE)); private final Option postsPerPage = - new DefaultOption(10, range(1, MAX_VALUE)); + new DefaultOption<>(10, range(1, MAX_VALUE)); private final Option imagesPerPage = - new DefaultOption(9, range(1, MAX_VALUE)); + new DefaultOption<>(9, range(1, MAX_VALUE)); private final Option charactersPerPost = - new DefaultOption(400, Predicates.or( + new DefaultOption<>(400, Predicates.or( range(50, MAX_VALUE), equalTo(-1))); private final Option postCutOffLength = - new DefaultOption(200, range(50, MAX_VALUE)); + new DefaultOption<>(200, range(50, MAX_VALUE)); private final Option requireFullAccess = - new DefaultOption(false); + new DefaultOption<>(false); private final Option positiveTrust = - new DefaultOption(75, range(0, 100)); + new DefaultOption<>(75, range(0, 100)); private final Option negativeTrust = - new DefaultOption(-25, range(-100, 100)); + new DefaultOption<>(-25, range(-100, 100)); private final Option trustComment = - new DefaultOption("Set from Sone Web Interface"); + new DefaultOption<>("Set from Sone Web Interface"); private final Option activateFcpInterface = - new DefaultOption(false); + new DefaultOption<>(false); private final Option fcpFullAccessRequired = - new DefaultOption(ALWAYS); + new DefaultOption<>(ALWAYS); public Preferences(EventBus eventBus) { this.eventBus = eventBus; diff --git a/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java b/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java index 91bf13b..c0d491b 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneDownloaderImpl.java @@ -62,7 +62,7 @@ public class SoneDownloaderImpl extends AbstractService implements SoneDownloade private final FreenetInterface freenetInterface; /** The sones to update. */ - private final Set sones = new HashSet(); + private final Set sones = new HashSet<>(); @Inject SoneDownloaderImpl(UpdatedSoneProcessor updatedSoneProcessor, FreenetInterface freenetInterface, SoneParser soneParser) { diff --git a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java index ba5d0a9..3e1fd15 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneInserter.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneInserter.java @@ -283,7 +283,7 @@ public class SoneInserter extends AbstractService { class InsertInformation implements Closeable { /** All properties of the Sone, copied for thread safety. */ - private final Map soneProperties = new HashMap(); + private final Map soneProperties = new HashMap<>(); private final String fingerprint; private final ManifestCreator manifestCreator; @@ -295,7 +295,7 @@ public class SoneInserter extends AbstractService { */ public InsertInformation(Sone sone) { this.fingerprint = sone.getFingerprint(); - Map soneProperties = new HashMap(); + Map soneProperties = new HashMap<>(); soneProperties.put("id", sone.getId()); soneProperties.put("name", sone.getName()); soneProperties.put("time", currentTimeMillis()); @@ -303,8 +303,8 @@ public class SoneInserter extends AbstractService { soneProperties.put("profile", sone.getProfile()); soneProperties.put("posts", Ordering.from(Post.NEWEST_FIRST).sortedCopy(sone.getPosts())); soneProperties.put("replies", Ordering.from(Reply.TIME_COMPARATOR).reverse().sortedCopy(sone.getReplies())); - soneProperties.put("likedPostIds", new HashSet(sone.getLikedPostIds())); - soneProperties.put("likedReplyIds", new HashSet(sone.getLikedReplyIds())); + soneProperties.put("likedPostIds", new HashSet<>(sone.getLikedPostIds())); + soneProperties.put("likedReplyIds", new HashSet<>(sone.getLikedReplyIds())); soneProperties.put("albums", FluentIterable.from(sone.getRootAlbum().getAlbums()).transformAndConcat(Album.FLATTENER).filter(NOT_EMPTY).toList()); manifestCreator = new ManifestCreator(core, soneProperties); } @@ -328,7 +328,7 @@ public class SoneInserter extends AbstractService { * @return The manifest entries for the Sone insert */ public HashMap generateManifestEntries() { - HashMap manifestEntries = new HashMap(); + HashMap manifestEntries = new HashMap<>(); /* first, create an index.html. */ manifestEntries.put("index.html", manifestCreator.createManifestElement( @@ -358,7 +358,7 @@ public class SoneInserter extends AbstractService { private final Core core; private final Map soneProperties; - private final Set buckets = new HashSet(); + private final Set buckets = new HashSet<>(); ManifestCreator(Core core, Map soneProperties) { this.core = core; diff --git a/src/main/java/net/pterodactylus/sone/core/SoneParser.java b/src/main/java/net/pterodactylus/sone/core/SoneParser.java index ce0606b..1f30565 100644 --- a/src/main/java/net/pterodactylus/sone/core/SoneParser.java +++ b/src/main/java/net/pterodactylus/sone/core/SoneParser.java @@ -166,7 +166,7 @@ public class SoneParser { /* parse posts. */ SimpleXML postsXml = soneXml.getNode("posts"); - Set posts = new HashSet(); + Set posts = new HashSet<>(); if (postsXml == null) { /* TODO - mark Sone as bad. */ logger.log(Level.WARNING, String.format("Downloaded Sone %s has no posts!", sone)); @@ -199,7 +199,7 @@ public class SoneParser { /* parse replies. */ SimpleXML repliesXml = soneXml.getNode("replies"); - Set replies = new HashSet(); + Set replies = new HashSet<>(); if (repliesXml == null) { /* TODO - mark Sone as bad. */ logger.log(Level.WARNING, String.format("Downloaded Sone %s has no replies!", sone)); @@ -229,7 +229,7 @@ public class SoneParser { /* parse liked post IDs. */ SimpleXML likePostIdsXml = soneXml.getNode("post-likes"); - Set likedPostIds = new HashSet(); + Set likedPostIds = new HashSet<>(); if (likePostIdsXml == null) { /* TODO - mark Sone as bad. */ logger.log(Level.WARNING, String.format("Downloaded Sone %s has no post likes!", sone)); @@ -242,7 +242,7 @@ public class SoneParser { /* parse liked reply IDs. */ SimpleXML likeReplyIdsXml = soneXml.getNode("reply-likes"); - Set likedReplyIds = new HashSet(); + Set likedReplyIds = new HashSet<>(); if (likeReplyIdsXml == null) { /* TODO - mark Sone as bad. */ logger.log(Level.WARNING, String.format("Downloaded Sone %s has no reply likes!", sone)); @@ -255,8 +255,8 @@ public class SoneParser { /* parse albums. */ SimpleXML albumsXml = soneXml.getNode("albums"); - Map allImages = new HashMap(); - List topLevelAlbums = new ArrayList(); + Map allImages = new HashMap<>(); + List topLevelAlbums = new ArrayList<>(); if (albumsXml != null) { for (SimpleXML albumXml : albumsXml.getNodes("album")) { String id = albumXml.getValue("id", null); diff --git a/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java b/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java index 8cac572..f120f85 100644 --- a/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java +++ b/src/main/java/net/pterodactylus/sone/core/WebOfTrustUpdaterImpl.java @@ -55,7 +55,7 @@ public class WebOfTrustUpdaterImpl extends AbstractService implements WebOfTrust private final WebOfTrustConnector webOfTrustConnector; /** The queue for jobs. */ - private final BlockingQueue updateJobs = new LinkedBlockingQueue(); + private final BlockingQueue updateJobs = new LinkedBlockingQueue<>(); /** * Creates a new trust updater. diff --git a/src/main/java/net/pterodactylus/sone/data/Album.java b/src/main/java/net/pterodactylus/sone/data/Album.java index f90a42f..1104929 100644 --- a/src/main/java/net/pterodactylus/sone/data/Album.java +++ b/src/main/java/net/pterodactylus/sone/data/Album.java @@ -44,7 +44,7 @@ public interface Album extends Identified, Fingerprintable { if (album == null) { return emptyList(); } - List albums = new ArrayList(); + List albums = new ArrayList<>(); albums.add(album); for (Album subAlbum : album.getAlbums()) { albums.addAll(FluentIterable.from(ImmutableList.of(subAlbum)).transformAndConcat(FLATTENER).toList()); diff --git a/src/main/java/net/pterodactylus/sone/data/Profile.java b/src/main/java/net/pterodactylus/sone/data/Profile.java index d3ce38e..c3ffe60 100644 --- a/src/main/java/net/pterodactylus/sone/data/Profile.java +++ b/src/main/java/net/pterodactylus/sone/data/Profile.java @@ -282,7 +282,7 @@ public class Profile implements Fingerprintable { */ @Nonnull public List getFields() { - return new ArrayList(fields); + return new ArrayList<>(fields); } /** diff --git a/src/main/java/net/pterodactylus/sone/data/impl/AlbumImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/AlbumImpl.java index f87273c..dff3912 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/AlbumImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/AlbumImpl.java @@ -51,13 +51,13 @@ public class AlbumImpl implements Album { private final Sone sone; /** Nested albums. */ - private final List albums = new ArrayList(); + private final List albums = new ArrayList<>(); /** The image IDs in order. */ - private final List imageIds = new ArrayList(); + private final List imageIds = new ArrayList<>(); /** The images in this album. */ - private final Map images = new HashMap(); + private final Map images = new HashMap<>(); /** The parent album. */ private Album parent; @@ -100,7 +100,7 @@ public class AlbumImpl implements Album { @Override public List getAlbums() { - return new ArrayList(albums); + return new ArrayList<>(albums); } @Override @@ -152,7 +152,7 @@ public class AlbumImpl implements Album { @Override public List getImages() { - return new ArrayList(Collections2.filter(Collections2.transform(imageIds, new Function() { + return new ArrayList<>(Collections2.filter(Collections2.transform(imageIds, new Function() { @Override @SuppressWarnings("synthetic-access") diff --git a/src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java b/src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java index e4bedb0..2a5d29a 100644 --- a/src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java +++ b/src/main/java/net/pterodactylus/sone/data/impl/SoneImpl.java @@ -93,16 +93,16 @@ public class SoneImpl implements Sone { private volatile boolean known; /** All posts. */ - private final Set posts = new CopyOnWriteArraySet(); + private final Set posts = new CopyOnWriteArraySet<>(); /** All replies. */ - private final Set replies = new CopyOnWriteArraySet(); + private final Set replies = new CopyOnWriteArraySet<>(); /** The IDs of all liked posts. */ - private final Set likedPostIds = new CopyOnWriteArraySet(); + private final Set likedPostIds = new CopyOnWriteArraySet<>(); /** The IDs of all liked replies. */ - private final Set likedReplyIds = new CopyOnWriteArraySet(); + private final Set likedReplyIds = new CopyOnWriteArraySet<>(); /** The root album containing all albums. */ private final Album rootAlbum = new AlbumImpl(this); @@ -381,7 +381,7 @@ public class SoneImpl implements Sone { public List getPosts() { List sortedPosts; synchronized (this) { - sortedPosts = new ArrayList(posts); + sortedPosts = new ArrayList<>(posts); } Collections.sort(sortedPosts, Post.NEWEST_FIRST); return sortedPosts; @@ -642,7 +642,7 @@ public class SoneImpl implements Sone { } hash.putString(")"); - List replies = new ArrayList(getReplies()); + List replies = new ArrayList<>(getReplies()); Collections.sort(replies, Reply.TIME_COMPARATOR); hash.putString("Replies("); for (PostReply reply : replies) { @@ -650,7 +650,7 @@ public class SoneImpl implements Sone { } hash.putString(")"); - List likedPostIds = new ArrayList(getLikedPostIds()); + List likedPostIds = new ArrayList<>(getLikedPostIds()); Collections.sort(likedPostIds); hash.putString("LikedPosts("); for (String likedPostId : likedPostIds) { @@ -658,7 +658,7 @@ public class SoneImpl implements Sone { } hash.putString(")"); - List likedReplyIds = new ArrayList(getLikedReplyIds()); + List likedReplyIds = new ArrayList<>(getLikedReplyIds()); Collections.sort(likedReplyIds); hash.putString("LikedReplies("); for (String likedReplyId : likedReplyIds) { diff --git a/src/main/java/net/pterodactylus/sone/database/memory/ConfigurationLoader.java b/src/main/java/net/pterodactylus/sone/database/memory/ConfigurationLoader.java index 661bfe8..268f1a2 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/ConfigurationLoader.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/ConfigurationLoader.java @@ -93,7 +93,7 @@ public class ConfigurationLoader { } private Set loadIds(String prefix) { - Set ids = new HashSet(); + Set ids = new HashSet<>(); int idCounter = 0; while (true) { String id = configuration diff --git a/src/main/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabase.java b/src/main/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabase.java index cc0127c..1a4e119 100644 --- a/src/main/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabase.java +++ b/src/main/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabase.java @@ -22,7 +22,7 @@ public class MemoryBookmarkDatabase implements BookmarkDatabase { private final ReadWriteLock lock = new ReentrantReadWriteLock(); private final MemoryDatabase memoryDatabase; private final ConfigurationLoader configurationLoader; - private final Set bookmarkedPosts = new HashSet(); + private final Set bookmarkedPosts = new HashSet<>(); public MemoryBookmarkDatabase(MemoryDatabase memoryDatabase, ConfigurationLoader configurationLoader) { diff --git a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java index 11c1611..e190aef 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java +++ b/src/main/java/net/pterodactylus/sone/fcp/FcpInterface.java @@ -81,7 +81,7 @@ public class FcpInterface { private final AtomicBoolean active = new AtomicBoolean(); /** What function full access is required for. */ - private final AtomicReference fullAccessRequired = new AtomicReference(FullAccessRequired.ALWAYS); + private final AtomicReference fullAccessRequired = new AtomicReference<>(FullAccessRequired.ALWAYS); /** All available FCP commands. */ private final Map commands; diff --git a/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java b/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java index 1e2ca7d..d837145 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/GetPostFeedCommand.java @@ -57,7 +57,7 @@ public class GetPostFeedCommand extends AbstractSoneCommand { int startPost = getInt(parameters, "StartPost", 0); int maxPosts = getInt(parameters, "MaxPosts", -1); - Collection allPosts = new HashSet(); + Collection allPosts = new HashSet<>(); allPosts.addAll(sone.getPosts()); for (String friendSoneId : sone.getFriends()) { Sone friendSone = getCore().getSone(friendSoneId); @@ -69,7 +69,7 @@ public class GetPostFeedCommand extends AbstractSoneCommand { allPosts.addAll(getCore().getDirectedPosts(sone.getId())); allPosts = Collections2.filter(allPosts, Post.FUTURE_POSTS_FILTER); - List sortedPosts = new ArrayList(allPosts); + List sortedPosts = new ArrayList<>(allPosts); Collections.sort(sortedPosts, Post.NEWEST_FIRST); if (sortedPosts.size() < startPost) { diff --git a/src/main/java/net/pterodactylus/sone/fcp/GetSonesCommand.java b/src/main/java/net/pterodactylus/sone/fcp/GetSonesCommand.java index 3ff234a..2c53562 100644 --- a/src/main/java/net/pterodactylus/sone/fcp/GetSonesCommand.java +++ b/src/main/java/net/pterodactylus/sone/fcp/GetSonesCommand.java @@ -49,7 +49,7 @@ public class GetSonesCommand extends AbstractSoneCommand { public Response execute(SimpleFieldSet parameters) { int startSone = getInt(parameters, "StartSone", 0); int maxSones = getInt(parameters, "MaxSones", -1); - List sones = new ArrayList(getCore().getSones()); + List sones = new ArrayList<>(getCore().getSones()); if (sones.size() < startSone) { return new Response("Sones", encodeSones(Collections. emptyList(), "Sones.")); } diff --git a/src/main/java/net/pterodactylus/sone/freenet/L10nFilter.java b/src/main/java/net/pterodactylus/sone/freenet/L10nFilter.java index 229b8e1..12e1c12 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/L10nFilter.java +++ b/src/main/java/net/pterodactylus/sone/freenet/L10nFilter.java @@ -71,7 +71,7 @@ public class L10nFilter implements Filter { if (data instanceof L10nText) { return ((L10nText) data).getParameters(); } - List parameterValues = new ArrayList(); + List parameterValues = new ArrayList<>(); int parameterIndex = 0; while (parameters.containsKey(String.valueOf(parameterIndex))) { Object value = parameters.get(String.valueOf(parameterIndex)); diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java index a17b0bc..ff7e65f 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityLoader.java @@ -55,7 +55,7 @@ public class IdentityLoader { } private Map> loadTrustedIdentitiesForOwnIdentities(Collection ownIdentities) throws PluginException { - Map> currentIdentities = new HashMap>(); + Map> currentIdentities = new HashMap<>(); for (OwnIdentity ownIdentity : ownIdentities) { if (identityDoesNotHaveTheCorrectContext(ownIdentity)) { diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java index a9f3613..7d8d1e4 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/IdentityManagerImpl.java @@ -107,7 +107,7 @@ public class IdentityManagerImpl extends AbstractService implements IdentityMana @Override public Set getAllOwnIdentities() { synchronized (currentOwnIdentities) { - return new HashSet(currentOwnIdentities); + return new HashSet<>(currentOwnIdentities); } } @@ -120,7 +120,7 @@ public class IdentityManagerImpl extends AbstractService implements IdentityMana */ @Override protected void serviceRun() { - Map> oldIdentities = new HashMap>(); + Map> oldIdentities = new HashMap<>(); while (!shouldStop()) { try { diff --git a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java index 1d30efb..de3f23a 100644 --- a/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java +++ b/src/main/java/net/pterodactylus/sone/freenet/wot/WebOfTrustConnector.java @@ -96,7 +96,7 @@ public class WebOfTrustConnector { Reply reply = performRequest(SimpleFieldSetConstructor.create().put("Message", "GetOwnIdentities").get()); SimpleFieldSet fields = reply.getFields(); int ownIdentityCounter = -1; - Set ownIdentities = new HashSet(); + Set ownIdentities = new HashSet<>(); while (true) { String id = fields.get("Identity" + ++ownIdentityCounter); if (id == null) { @@ -142,7 +142,7 @@ public class WebOfTrustConnector { public Set loadTrustedIdentities(OwnIdentity ownIdentity, Optional context) throws PluginException { Reply reply = performRequest(SimpleFieldSetConstructor.create().put("Message", "GetIdentitiesByScore").put("Truster", ownIdentity.getId()).put("Selection", "+").put("Context", context.or("")).put("WantTrustValues", "true").get()); SimpleFieldSet fields = reply.getFields(); - Set identities = new HashSet(); + Set identities = new HashSet<>(); int identityCounter = -1; while (true) { String id = fields.get("Identity" + ++identityCounter); @@ -329,7 +329,7 @@ public class WebOfTrustConnector { * @return The parsed contexts */ private static Set parseContexts(String prefix, SimpleFieldSet fields) { - Set contexts = new HashSet(); + Set contexts = new HashSet<>(); int contextCounter = -1; while (true) { String context = fields.get(prefix + "Context" + ++contextCounter); @@ -351,7 +351,7 @@ public class WebOfTrustConnector { * @return The parsed properties */ private static Map parseProperties(String prefix, SimpleFieldSet fields) { - Map properties = new HashMap(); + Map properties = new HashMap<>(); int propertiesCounter = -1; while (true) { String propertyName = fields.get(prefix + "Property" + ++propertiesCounter + ".Name"); diff --git a/src/main/java/net/pterodactylus/sone/main/DebugLoaders.java b/src/main/java/net/pterodactylus/sone/main/DebugLoaders.java index 8317290..c42b056 100644 --- a/src/main/java/net/pterodactylus/sone/main/DebugLoaders.java +++ b/src/main/java/net/pterodactylus/sone/main/DebugLoaders.java @@ -28,7 +28,7 @@ public class DebugLoaders implements Loaders { @Override public Page loadStaticPage(String basePath, String prefix, String mimeType) { - return new ReloadingPage(basePath, new File(filesystemPath, prefix).getAbsolutePath(), mimeType); + return new ReloadingPage<>(basePath, new File(filesystemPath, prefix).getAbsolutePath(), mimeType); } @Override diff --git a/src/main/java/net/pterodactylus/sone/notify/ListNotification.java b/src/main/java/net/pterodactylus/sone/notify/ListNotification.java index 039639e..11b0829 100644 --- a/src/main/java/net/pterodactylus/sone/notify/ListNotification.java +++ b/src/main/java/net/pterodactylus/sone/notify/ListNotification.java @@ -37,7 +37,7 @@ public class ListNotification extends TemplateNotification { private final String key; /** The list of new elements. */ - private final List elements = new CopyOnWriteArrayList(); + private final List elements = new CopyOnWriteArrayList<>(); /** * Creates a new list notification. @@ -96,7 +96,7 @@ public class ListNotification extends TemplateNotification { * @return The current list of elements */ public List getElements() { - return new ArrayList(elements); + return new ArrayList<>(elements); } /** diff --git a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilter.java b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilter.java index 5db5258..2308353 100644 --- a/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilter.java +++ b/src/main/java/net/pterodactylus/sone/notify/ListNotificationFilter.java @@ -65,7 +65,7 @@ public class ListNotificationFilter { */ @SuppressWarnings("unchecked") public List filterNotifications(Collection notifications, Sone currentSone) { - List filteredNotifications = new ArrayList(); + List filteredNotifications = new ArrayList<>(); for (Notification notification : notifications) { if (notification.getId().equals("new-sone-notification")) { if ((currentSone != null) && !currentSone.getOptions().isShowNewSoneNotifications()) { @@ -126,7 +126,7 @@ public class ListNotificationFilter { if (newPosts.size() == postNotification.getElements().size()) { return Optional.of(postNotification); } - ListNotification filteredNotification = new ListNotification(postNotification); + ListNotification filteredNotification = new ListNotification<>(postNotification); filteredNotification.setElements(newPosts); filteredNotification.setLastUpdateTime(postNotification.getLastUpdatedTime()); return Optional.of(filteredNotification); @@ -155,7 +155,7 @@ public class ListNotificationFilter { if (newReplies.size() == newReplyNotification.getElements().size()) { return Optional.of(newReplyNotification); } - ListNotification filteredNotification = new ListNotification(newReplyNotification); + ListNotification filteredNotification = new ListNotification<>(newReplyNotification); filteredNotification.setElements(newReplies); filteredNotification.setLastUpdateTime(newReplyNotification.getLastUpdatedTime()); return Optional.of(filteredNotification); diff --git a/src/main/java/net/pterodactylus/sone/template/AlbumAccessor.java b/src/main/java/net/pterodactylus/sone/template/AlbumAccessor.java index f7b6f62..909f498 100644 --- a/src/main/java/net/pterodactylus/sone/template/AlbumAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/AlbumAccessor.java @@ -43,7 +43,7 @@ public class AlbumAccessor extends ReflectionAccessor { public Object get(TemplateContext templateContext, Object object, String member) { Album album = (Album) object; if ("backlinks".equals(member)) { - List backlinks = new ArrayList(); + List backlinks = new ArrayList<>(); Album currentAlbum = album; while (!currentAlbum.isRoot()) { backlinks.add(0, new Link("imageBrowser.html?album=" + currentAlbum.getId(), currentAlbum.getTitle())); diff --git a/src/main/java/net/pterodactylus/sone/template/CollectionAccessor.java b/src/main/java/net/pterodactylus/sone/template/CollectionAccessor.java index c9c7374..a8f87ca 100644 --- a/src/main/java/net/pterodactylus/sone/template/CollectionAccessor.java +++ b/src/main/java/net/pterodactylus/sone/template/CollectionAccessor.java @@ -45,7 +45,7 @@ public class CollectionAccessor extends ReflectionAccessor { public Object get(TemplateContext templateContext, Object object, String member) { Collection collection = (Collection) object; if (member.equals("soneNames")) { - List sones = new ArrayList(); + List sones = new ArrayList<>(); for (Object sone : collection) { if (!(sone instanceof Sone)) { continue; diff --git a/src/main/java/net/pterodactylus/sone/template/FilesystemTemplate.java b/src/main/java/net/pterodactylus/sone/template/FilesystemTemplate.java index dfc1dd7..7c7da4c 100644 --- a/src/main/java/net/pterodactylus/sone/template/FilesystemTemplate.java +++ b/src/main/java/net/pterodactylus/sone/template/FilesystemTemplate.java @@ -26,9 +26,9 @@ import com.google.common.base.Charsets; public class FilesystemTemplate extends Template { private final String filename; - private final AtomicReference lastTemplate = new AtomicReference(); + private final AtomicReference lastTemplate = new AtomicReference<>(); private final TemplateContext initialContext = new TemplateContext(); - private final List parts = new ArrayList(); + private final List parts = new ArrayList<>(); public FilesystemTemplate(String filename) { this.filename = filename; diff --git a/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java b/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java index b204706..87b4fe5 100644 --- a/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/RequestChangeFilter.java @@ -46,7 +46,7 @@ public class RequestChangeFilter implements Filter { String name = String.valueOf(parameters.get("name")); String value = String.valueOf(parameters.get("value")); - Map values = new HashMap(); + Map values = new HashMap<>(); Collection parameterNames = request.getHttpRequest().getParameterNames(); for (String parameterName : parameterNames) { values.put(parameterName, request.getHttpRequest().getParam(parameterName)); diff --git a/src/main/java/net/pterodactylus/sone/template/UniqueElementFilter.java b/src/main/java/net/pterodactylus/sone/template/UniqueElementFilter.java index 4705e6f..5ec2cd9 100644 --- a/src/main/java/net/pterodactylus/sone/template/UniqueElementFilter.java +++ b/src/main/java/net/pterodactylus/sone/template/UniqueElementFilter.java @@ -38,7 +38,7 @@ public class UniqueElementFilter implements Filter { if (!(data instanceof Collection)) { return data; } - return new HashSet((Collection) data); + return new HashSet<>((Collection) data); } } diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 5342292..cd776d7 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -237,7 +237,7 @@ public class WebInterface implements SessionProvider { private final SonePlugin sonePlugin; /** The registered toadlets. */ - private final List pageToadlets = new ArrayList(); + private final List pageToadlets = new ArrayList<>(); /** The form password. */ private final String formPassword; @@ -281,7 +281,7 @@ public class WebInterface implements SessionProvider { private final ListNotification mentionNotification; /** Notifications for sone inserts. */ - private final Map soneInsertNotifications = new HashMap(); + private final Map soneInsertNotifications = new HashMap<>(); /** Sone locked notification ticker objects. */ private final Map> lockedSonesTickerObjects = Collections.synchronizedMap(new HashMap>()); @@ -366,37 +366,37 @@ public class WebInterface implements SessionProvider { /* create notifications. */ Template newSoneNotificationTemplate = loaders.loadTemplate("/templates/notify/newSoneNotification.html"); - newSoneNotification = new ListNotification("new-sone-notification", "sones", newSoneNotificationTemplate, false); + newSoneNotification = new ListNotification<>("new-sone-notification", "sones", newSoneNotificationTemplate, false); Template newPostNotificationTemplate = loaders.loadTemplate("/templates/notify/newPostNotification.html"); - newPostNotification = new ListNotification("new-post-notification", "posts", newPostNotificationTemplate, false); + newPostNotification = new ListNotification<>("new-post-notification", "posts", newPostNotificationTemplate, false); Template localPostNotificationTemplate = loaders.loadTemplate("/templates/notify/newPostNotification.html"); - localPostNotification = new ListNotification("local-post-notification", "posts", localPostNotificationTemplate, false); + localPostNotification = new ListNotification<>("local-post-notification", "posts", localPostNotificationTemplate, false); Template newReplyNotificationTemplate = loaders.loadTemplate("/templates/notify/newReplyNotification.html"); - newReplyNotification = new ListNotification("new-reply-notification", "replies", newReplyNotificationTemplate, false); + newReplyNotification = new ListNotification<>("new-reply-notification", "replies", newReplyNotificationTemplate, false); Template localReplyNotificationTemplate = loaders.loadTemplate("/templates/notify/newReplyNotification.html"); - localReplyNotification = new ListNotification("local-reply-notification", "replies", localReplyNotificationTemplate, false); + localReplyNotification = new ListNotification<>("local-reply-notification", "replies", localReplyNotificationTemplate, false); Template mentionNotificationTemplate = loaders.loadTemplate("/templates/notify/mentionNotification.html"); - mentionNotification = new ListNotification("mention-notification", "posts", mentionNotificationTemplate, false); + mentionNotification = new ListNotification<>("mention-notification", "posts", mentionNotificationTemplate, false); Template lockedSonesTemplate = loaders.loadTemplate("/templates/notify/lockedSonesNotification.html"); - lockedSonesNotification = new ListNotification("sones-locked-notification", "sones", lockedSonesTemplate); + lockedSonesNotification = new ListNotification<>("sones-locked-notification", "sones", lockedSonesTemplate); Template newVersionTemplate = loaders.loadTemplate("/templates/notify/newVersionNotification.html"); newVersionNotification = new TemplateNotification("new-version-notification", newVersionTemplate); Template insertingImagesTemplate = loaders.loadTemplate("/templates/notify/inserting-images-notification.html"); - insertingImagesNotification = new ListNotification("inserting-images-notification", "images", insertingImagesTemplate); + insertingImagesNotification = new ListNotification<>("inserting-images-notification", "images", insertingImagesTemplate); Template insertedImagesTemplate = loaders.loadTemplate("/templates/notify/inserted-images-notification.html"); - insertedImagesNotification = new ListNotification("inserted-images-notification", "images", insertedImagesTemplate); + insertedImagesNotification = new ListNotification<>("inserted-images-notification", "images", insertedImagesTemplate); Template imageInsertFailedTemplate = loaders.loadTemplate("/templates/notify/image-insert-failed-notification.html"); - imageInsertFailedNotification = new ListNotification("image-insert-failed-notification", "images", imageInsertFailedTemplate); + imageInsertFailedNotification = new ListNotification<>("image-insert-failed-notification", "images", imageInsertFailedTemplate); } // @@ -829,7 +829,7 @@ public class WebInterface implements SessionProvider { */ private Collection getMentionedSones(String text) { /* we need no context to find mentioned Sones. */ - Set mentionedSones = new HashSet(); + Set mentionedSones = new HashSet<>(); for (Part part : soneTextParser.parse(text, null)) { if (part instanceof SonePart) { mentionedSones.add(((SonePart) part).getSone()); diff --git a/src/main/java/net/pterodactylus/sone/web/page/PageToadlet.java b/src/main/java/net/pterodactylus/sone/web/page/PageToadlet.java index c515e5f..16cf6c2 100644 --- a/src/main/java/net/pterodactylus/sone/web/page/PageToadlet.java +++ b/src/main/java/net/pterodactylus/sone/web/page/PageToadlet.java @@ -145,7 +145,7 @@ public class PageToadlet extends Toadlet implements LinkEnabledCallback, LinkFil try (AutoCloseableBucket pageBucket = new AutoCloseableBucket(pageRequest.getToadletContext().getBucketFactory().makeBucket(-1)); OutputStream pageBucketOutputStream = pageBucket.getBucket().getOutputStream()) { Response pageResponse = page.handleRequest(pageRequest, new Response(pageBucketOutputStream)); - MultiValueTable headers = new MultiValueTable(); + MultiValueTable headers = new MultiValueTable<>(); if (pageResponse.getHeaders() != null) { for (Header header : pageResponse.getHeaders()) { for (String value : header) { diff --git a/src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java b/src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java index 4a77dd4..c91de68 100644 --- a/src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java +++ b/src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java @@ -212,7 +212,7 @@ public class FreenetInterfaceTest { @Test public void insertingADirectory() throws InsertException, SoneException { FreenetURI freenetUri = mock(FreenetURI.class); - HashMap manifestEntries = new HashMap(); + HashMap manifestEntries = new HashMap<>(); String defaultFile = "index.html"; FreenetURI resultingUri = mock(FreenetURI.class); when(highLevelSimpleClient.insertManifest(eq(freenetUri), eq(manifestEntries), eq(defaultFile))).thenReturn(resultingUri); diff --git a/src/test/java/net/pterodactylus/sone/core/SoneInserterTest.java b/src/test/java/net/pterodactylus/sone/core/SoneInserterTest.java index 32926e8..94eabb0 100644 --- a/src/test/java/net/pterodactylus/sone/core/SoneInserterTest.java +++ b/src/test/java/net/pterodactylus/sone/core/SoneInserterTest.java @@ -248,7 +248,7 @@ public class SoneInserterTest { @Test public void templateIsRenderedCorrectlyForManifestElement() throws IOException { - Map soneProperties = new HashMap(); + Map soneProperties = new HashMap<>(); soneProperties.put("id", "SoneId"); ManifestCreator manifestCreator = new ManifestCreator(core, soneProperties); long now = currentTimeMillis(); @@ -264,7 +264,7 @@ public class SoneInserterTest { @Test public void invalidTemplateReturnsANullManifestElement() { - Map soneProperties = new HashMap(); + Map soneProperties = new HashMap<>(); ManifestCreator manifestCreator = new ManifestCreator(core, soneProperties); assertThat(manifestCreator.createManifestElement("test.txt", "plain/text; charset=utf-8", @@ -274,7 +274,7 @@ public class SoneInserterTest { @Test public void errorWhileRenderingTemplateReturnsANullManifestElement() { - Map soneProperties = new HashMap(); + Map soneProperties = new HashMap<>(); ManifestCreator manifestCreator = new ManifestCreator(core, soneProperties); when(core.toString()).thenThrow(NullPointerException.class); assertThat(manifestCreator.createManifestElement("test.txt", diff --git a/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java b/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java index fa5b0b1..400b9ae 100644 --- a/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java +++ b/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java @@ -68,20 +68,20 @@ public class SoneParserTest { private final Sone sone = mock(Sone.class); private FreenetURI requestUri = mock(FreenetURI.class); private final PostBuilder postBuilder = mock(PostBuilder.class); - private final List createdPosts = new ArrayList(); + private final List createdPosts = new ArrayList<>(); private Post post = mock(Post.class); private final PostReplyBuilder postReplyBuilder = mock(PostReplyBuilder.class); - private final Set createdPostReplies = new HashSet(); + private final Set createdPostReplies = new HashSet<>(); private PostReply postReply = mock(PostReply.class); private final AlbumBuilder albumBuilder = mock(AlbumBuilder.class); private final ListMultimap nestedAlbums = ArrayListMultimap.create(); private final ListMultimap albumImages = ArrayListMultimap.create(); private Album album = mock(Album.class); - private final Map albums = new HashMap(); + private final Map albums = new HashMap<>(); private final ImageBuilder imageBuilder = mock(ImageBuilder.class); private Image image = mock(Image.class); - private final Map images = new HashMap(); + private final Map images = new HashMap<>(); @Before public void setupSone() { diff --git a/src/test/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabaseTest.java b/src/test/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabaseTest.java index 24481bf..188b740 100644 --- a/src/test/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabaseTest.java +++ b/src/test/java/net/pterodactylus/sone/database/memory/MemoryBookmarkDatabaseTest.java @@ -33,7 +33,7 @@ public class MemoryBookmarkDatabaseTest { mock(ConfigurationLoader.class); private final MemoryBookmarkDatabase bookmarkDatabase = new MemoryBookmarkDatabase(memoryDatabase, configurationLoader); - private final Map posts = new HashMap(); + private final Map posts = new HashMap<>(); @Before public void setupMemoryDatabase() { @@ -67,7 +67,7 @@ public class MemoryBookmarkDatabaseTest { @Test public void bookmarkDatabaseRetainsBookmarkedPosts() { - Set allPosts = new HashSet(posts.values()); + Set allPosts = new HashSet<>(posts.values()); for (Post post : allPosts) { bookmarkDatabase.bookmarkPost(post); } @@ -98,7 +98,7 @@ public class MemoryBookmarkDatabaseTest { @Test public void removingABookmarkRemovesTheCorrectBookmark() { - Set allPosts = new HashSet(posts.values()); + Set allPosts = new HashSet<>(posts.values()); for (Post post : allPosts) { bookmarkDatabase.bookmarkPost(post); } diff --git a/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java b/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java index 8ac30e2..cfae82e 100644 --- a/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java +++ b/src/test/java/net/pterodactylus/sone/database/memory/MemoryDatabaseTest.java @@ -120,7 +120,7 @@ public class MemoryDatabaseTest { .withTime(4000L) .withText("reply2") .build(); - Set postReplies = new HashSet( + Set postReplies = new HashSet<>( asList(firstPostFirstReply, firstPostSecondReply, secondPostReply)); when(sone.getReplies()).thenReturn(postReplies); diff --git a/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSenderTest.java b/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSenderTest.java index 0b3e605..26d22a2 100644 --- a/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSenderTest.java +++ b/src/test/java/net/pterodactylus/sone/freenet/wot/IdentityChangeEventSenderTest.java @@ -75,14 +75,14 @@ public class IdentityChangeEventSenderTest { } private Map> createNewIdentities() { - Map> oldIdentities = new HashMap>(); + Map> oldIdentities = new HashMap<>(); oldIdentities.put(ownIdentities.get(1), asList(identities.get(3), identities.get(2))); oldIdentities.put(ownIdentities.get(2), asList(identities.get(1), identities.get(2))); return oldIdentities; } private Map> createOldIdentities() { - Map> oldIdentities = new HashMap>(); + Map> oldIdentities = new HashMap<>(); oldIdentities.put(ownIdentities.get(0), asList(identities.get(0), identities.get(1))); oldIdentities.put(ownIdentities.get(1), asList(identities.get(0), identities.get(1))); return oldIdentities; diff --git a/src/test/java/net/pterodactylus/sone/notify/ListNotificationTest.java b/src/test/java/net/pterodactylus/sone/notify/ListNotificationTest.java index a31621f..5e40f81 100644 --- a/src/test/java/net/pterodactylus/sone/notify/ListNotificationTest.java +++ b/src/test/java/net/pterodactylus/sone/notify/ListNotificationTest.java @@ -34,7 +34,7 @@ public class ListNotificationTest { public ListNotificationTest() { when(template.getInitialContext()).thenReturn(templateInitialContext); - listNotification = new ListNotification(ID, KEY, template); + listNotification = new ListNotification<>(ID, KEY, template); } @Test diff --git a/src/test/java/net/pterodactylus/sone/template/CollectionAccessorTest.java b/src/test/java/net/pterodactylus/sone/template/CollectionAccessorTest.java index af76458..e83693a 100644 --- a/src/test/java/net/pterodactylus/sone/template/CollectionAccessorTest.java +++ b/src/test/java/net/pterodactylus/sone/template/CollectionAccessorTest.java @@ -20,7 +20,7 @@ import org.junit.Test; public class CollectionAccessorTest { private final CollectionAccessor accessor = new CollectionAccessor(); - private final Collection collection = new ArrayList(); + private final Collection collection = new ArrayList<>(); @Before public void setupCollection() { diff --git a/src/test/java/net/pterodactylus/sone/template/FilesystemTemplateTest.java b/src/test/java/net/pterodactylus/sone/template/FilesystemTemplateTest.java index b96ed49..9259ef5 100644 --- a/src/test/java/net/pterodactylus/sone/template/FilesystemTemplateTest.java +++ b/src/test/java/net/pterodactylus/sone/template/FilesystemTemplateTest.java @@ -27,7 +27,7 @@ public class FilesystemTemplateTest { private final File tempFile; private final FilesystemTemplate filesystemTemplate; - private final AtomicReference stringWriter = new AtomicReference(new StringWriter()); + private final AtomicReference stringWriter = new AtomicReference<>(new StringWriter()); private final TemplateContext templateContext = new TemplateContext(); public FilesystemTemplateTest() throws IOException { diff --git a/src/test/java/net/pterodactylus/sone/template/GetPagePluginTest.java b/src/test/java/net/pterodactylus/sone/template/GetPagePluginTest.java index c1c4581..cefc8b0 100644 --- a/src/test/java/net/pterodactylus/sone/template/GetPagePluginTest.java +++ b/src/test/java/net/pterodactylus/sone/template/GetPagePluginTest.java @@ -24,7 +24,7 @@ public class GetPagePluginTest { private final TemplateContext context = mock(TemplateContext.class); private final FreenetRequest request = mock(FreenetRequest.class); private final Map parameters = - new HashMap(); + new HashMap<>(); private HTTPRequest httpRequest = mock(HTTPRequest.class); @Before diff --git a/src/test/java/net/pterodactylus/sone/test/TestAlbumBuilder.java b/src/test/java/net/pterodactylus/sone/test/TestAlbumBuilder.java index 25d67b5..e091566 100644 --- a/src/test/java/net/pterodactylus/sone/test/TestAlbumBuilder.java +++ b/src/test/java/net/pterodactylus/sone/test/TestAlbumBuilder.java @@ -24,8 +24,8 @@ import org.mockito.stubbing.Answer; public class TestAlbumBuilder implements AlbumBuilder { private final Album album = mock(Album.class); - private final List albums = new ArrayList(); - private final List images = new ArrayList(); + private final List albums = new ArrayList<>(); + private final List images = new ArrayList<>(); private Album parentAlbum; private String title; private String description; diff --git a/src/test/java/net/pterodactylus/sone/test/TestValue.java b/src/test/java/net/pterodactylus/sone/test/TestValue.java index d7e8759..6435d16 100644 --- a/src/test/java/net/pterodactylus/sone/test/TestValue.java +++ b/src/test/java/net/pterodactylus/sone/test/TestValue.java @@ -15,7 +15,7 @@ import com.google.common.base.Objects; */ public class TestValue implements Value { - private final AtomicReference value = new AtomicReference(); + private final AtomicReference value = new AtomicReference<>(); public TestValue(@Nullable T originalValue) { value.set(originalValue); @@ -58,7 +58,7 @@ public class TestValue implements Value { @Nonnull public static Value from(@Nullable T value) { - return new TestValue(value); + return new TestValue<>(value); } } diff --git a/src/test/java/net/pterodactylus/sone/utils/DefaultOptionTest.java b/src/test/java/net/pterodactylus/sone/utils/DefaultOptionTest.java index 8e6a93c..3c82c40 100644 --- a/src/test/java/net/pterodactylus/sone/utils/DefaultOptionTest.java +++ b/src/test/java/net/pterodactylus/sone/utils/DefaultOptionTest.java @@ -25,19 +25,19 @@ public class DefaultOptionTest { @Test public void defaultOptionReturnsDefaultValueWhenUnset() { - DefaultOption defaultOption = new DefaultOption(defaultValue); + DefaultOption defaultOption = new DefaultOption<>(defaultValue); assertThat(defaultOption.get(), is(defaultValue)); } @Test public void defaultOptionReturnsNullForRealWhenUnset() { - DefaultOption defaultOption = new DefaultOption(defaultValue); + DefaultOption defaultOption = new DefaultOption<>(defaultValue); assertThat(defaultOption.getReal(), nullValue()); } @Test public void defaultOptionWillReturnSetValue() { - DefaultOption defaultOption = new DefaultOption(defaultValue); + DefaultOption defaultOption = new DefaultOption<>(defaultValue); Object newValue = new Object(); defaultOption.set(newValue); assertThat(defaultOption.get(), is(newValue)); @@ -45,40 +45,40 @@ public class DefaultOptionTest { @Test public void defaultOptionWithValidatorAcceptsValidValues() { - DefaultOption defaultOption = new DefaultOption(defaultValue, matchesAcceptedValue); + DefaultOption defaultOption = new DefaultOption<>(defaultValue, matchesAcceptedValue); defaultOption.set(acceptedValue); assertThat(defaultOption.get(), is(acceptedValue)); } @Test(expected = IllegalArgumentException.class) public void defaultOptionWithValidatorRejectsInvalidValues() { - DefaultOption defaultOption = new DefaultOption(defaultValue, matchesAcceptedValue); + DefaultOption defaultOption = new DefaultOption<>(defaultValue, matchesAcceptedValue); defaultOption.set(new Object()); } @Test public void defaultOptionValidatesObjectsCorrectly() { - DefaultOption defaultOption = new DefaultOption(defaultValue, matchesAcceptedValue); + DefaultOption defaultOption = new DefaultOption<>(defaultValue, matchesAcceptedValue); assertThat(defaultOption.validate(acceptedValue), is(true)); assertThat(defaultOption.validate(new Object()), is(false)); } @Test public void settingToNullWillRestoreDefaultValue() { - DefaultOption defaultOption = new DefaultOption(defaultValue); + DefaultOption defaultOption = new DefaultOption<>(defaultValue); defaultOption.set(null); assertThat(defaultOption.get(), is(defaultValue)); } @Test public void validateWithoutValidatorWillValidateNull() { - DefaultOption defaultOption = new DefaultOption(defaultValue); + DefaultOption defaultOption = new DefaultOption<>(defaultValue); assertThat(defaultOption.validate(null), is(true)); } @Test public void validateWithValidatorWillValidateNull() { - DefaultOption defaultOption = new DefaultOption(defaultValue, matchesAcceptedValue); + DefaultOption defaultOption = new DefaultOption<>(defaultValue, matchesAcceptedValue); assertThat(defaultOption.validate(null), is(true)); } -- 2.7.4