Finally use the diamond operator throughout.

This commit is contained in:
Major-
2014-08-14 21:33:30 +01:00
parent 2f0a062929
commit 9ec73e2602
13 changed files with 18 additions and 23 deletions
@@ -15,7 +15,7 @@ public final class CommandDispatcher {
/** /**
* A map of command strings to command listeners. * A map of command strings to command listeners.
*/ */
private final Map<String, CommandListener> listeners = new HashMap<String, CommandListener>(); private final Map<String, CommandListener> listeners = new HashMap<>();
/** /**
* Creates the command dispatcher and registers a listener for the credits command. * Creates the command dispatcher and registers a listener for the credits command.
@@ -16,7 +16,7 @@ public final class EquipmentDefinition {
/** /**
* The equipment definitions. * The equipment definitions.
*/ */
private static final Map<Integer, EquipmentDefinition> definitions = new HashMap<Integer, EquipmentDefinition>(); private static final Map<Integer, EquipmentDefinition> definitions = new HashMap<>();
/** /**
* Initialises the equipment definitions. * Initialises the equipment definitions.
+3 -4
View File
@@ -406,11 +406,10 @@ public final class Inventory implements Cloneable {
if (amount >= item.getAmount()) { if (amount >= item.getAmount()) {
set(slot, null); set(slot, null);
return item.getAmount(); return item.getAmount();
} else {
int newAmount = item.getAmount() - amount;
set(slot, new Item(item.getId(), newAmount));
return amount;
} }
int newAmount = item.getAmount() - amount;
set(slot, new Item(item.getId(), newAmount));
return amount;
} }
} }
return 0; return 0;
@@ -82,7 +82,7 @@ public final class MessageHandlerChainParser {
} }
Class<? extends Message> messageClass = (Class<? extends Message>) Class.forName(messageClassName); Class<? extends Message> messageClass = (Class<? extends Message>) Class.forName(messageClassName);
List<MessageHandler<?>> handlers = new ArrayList<MessageHandler<?>>(); List<MessageHandler<?>> handlers = new ArrayList<>();
for (XmlNode handlerNode : chainNode) { for (XmlNode handlerNode : chainNode) {
if (!handlerNode.getName().equals("handler")) { if (!handlerNode.getName().equals("handler")) {
@@ -33,8 +33,7 @@ public final class GamePacketEncoder extends MessageToMessageEncoder<GamePacket>
} }
@Override @Override
protected void encode(ChannelHandlerContext ctx, GamePacket msg, List<Object> out) throws Exception { protected void encode(ChannelHandlerContext ctx, GamePacket packet, List<Object> out) throws Exception {
GamePacket packet = (GamePacket) msg;
PacketType type = packet.getType(); PacketType type = packet.getType();
int headerLength = 1; int headerLength = 1;
int payloadLength = packet.getLength(); int payloadLength = packet.getLength();
@@ -312,9 +312,8 @@ public final class GamePacketReader {
int peek = buffer.getByte(buffer.readerIndex()); int peek = buffer.getByte(buffer.readerIndex());
if (peek < 128) { if (peek < 128) {
return buffer.readByte() - 64; return buffer.readByte() - 64;
} else {
return buffer.readShort() - 49152;
} }
return buffer.readShort() - 49152;
} }
/** /**
@@ -394,9 +393,8 @@ public final class GamePacketReader {
int peek = buffer.getByte(buffer.readerIndex()); int peek = buffer.getByte(buffer.readerIndex());
if (peek < 128) { if (peek < 128) {
return buffer.readByte(); return buffer.readByte();
} else {
return buffer.readShort() - 32768;
} }
return buffer.readShort() - 32768;
} }
/** /**
+1 -2
View File
@@ -941,9 +941,8 @@ public final class EquipmentUpdater {
} }
if (name.equals("Mithril arrow")) { if (name.equals("Mithril arrow")) {
return 1; return 1;
} else {
return 1;
} }
return 1;
} }
/** /**
+1 -1
View File
@@ -38,7 +38,7 @@ public final class NoteUpdater {
ItemDefinition.init(defs); ItemDefinition.init(defs);
os.writeShort(defs.length); os.writeShort(defs.length);
Map<Integer, Integer> itemToNote = new HashMap<Integer, Integer>(); Map<Integer, Integer> itemToNote = new HashMap<>();
for (int id = 0; id < defs.length; id++) { for (int id = 0; id < defs.length; id++) {
ItemDefinition def = ItemDefinition.lookup(id); ItemDefinition def = ItemDefinition.lookup(id);
+3 -3
View File
@@ -25,17 +25,17 @@ public final class UpdateDispatcher {
/** /**
* A queue for pending HTTP requests. * A queue for pending HTTP requests.
*/ */
private final BlockingQueue<ChannelRequest<HttpRequest>> httpQueue = new LinkedBlockingQueue<ChannelRequest<HttpRequest>>(); private final BlockingQueue<ChannelRequest<HttpRequest>> httpQueue = new LinkedBlockingQueue<>();
/** /**
* A queue for pending JAGGRAB requests. * A queue for pending JAGGRAB requests.
*/ */
private final BlockingQueue<ChannelRequest<JagGrabRequest>> jagGrabQueue = new LinkedBlockingQueue<ChannelRequest<JagGrabRequest>>(); private final BlockingQueue<ChannelRequest<JagGrabRequest>> jagGrabQueue = new LinkedBlockingQueue<>();
/** /**
* A queue for pending 'on-demand' requests. * A queue for pending 'on-demand' requests.
*/ */
private final BlockingQueue<ChannelRequest<OnDemandRequest>> onDemandQueue = new PriorityBlockingQueue<ChannelRequest<OnDemandRequest>>(); private final BlockingQueue<ChannelRequest<OnDemandRequest>> onDemandQueue = new PriorityBlockingQueue<>();
/** /**
* Dispatches a HTTP request. * Dispatches a HTTP request.
+1 -1
View File
@@ -40,7 +40,7 @@ public final class UpdateService extends Service {
/** /**
* A list of request workers. * A list of request workers.
*/ */
private final List<RequestWorker<?, ?>> workers = new ArrayList<RequestWorker<?, ?>>(); private final List<RequestWorker<?, ?>> workers = new ArrayList<>();
/** /**
* Creates the update service. * Creates the update service.
+1 -1
View File
@@ -104,7 +104,7 @@ public final class TextUtil {
for (char c : str.toLowerCase().toCharArray()) { for (char c : str.toLowerCase().toCharArray()) {
for (char validChar : FREQUENCY_ORDERED_CHARS) { for (char validChar : FREQUENCY_ORDERED_CHARS) {
if (c == validChar) { if (c == validChar) {
builder.append((char) c); builder.append(c);
break; break;
} }
} }
@@ -51,7 +51,7 @@ public final class PluginManager {
* @return The plugin map. * @return The plugin map.
*/ */
private Map<String, PluginMetaData> createMap(Collection<PluginMetaData> plugins) { private Map<String, PluginMetaData> createMap(Collection<PluginMetaData> plugins) {
Map<String, PluginMetaData> map = new HashMap<String, PluginMetaData>(); Map<String, PluginMetaData> map = new HashMap<>();
for (PluginMetaData plugin : plugins) { for (PluginMetaData plugin : plugins) {
map.put(plugin.getId(), plugin); map.put(plugin.getId(), plugin);
} }
+1 -1
View File
@@ -20,7 +20,7 @@ public final class XmlNode implements Iterable<XmlNode> {
/** /**
* The attribute map. * The attribute map.
*/ */
private final Map<String, String> attributes = new HashMap<String, String>(); private final Map<String, String> attributes = new HashMap<>();
/** /**
* The list of child nodes. * The list of child nodes.