Skip to content

Commit 3b907c4

Browse files
Squash more IDEA warnings
1 parent e516e9d commit 3b907c4

File tree

4 files changed

+82
-88
lines changed

4 files changed

+82
-88
lines changed

src/main/java/com/rabbitmq/jms/client/message/RMQBytesMessage.java

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ public void clearBodyInternal() throws JMSException {
413413
this.reading = false;
414414
}
415415

416-
private final byte[] getByteArray() {
416+
private byte[] getByteArray() {
417417
if (reading) return this.buf;
418418
else return this.bout.toByteArray();
419419
}
@@ -457,34 +457,30 @@ protected void readAmqpBody(byte[] barr) {
457457
* Utility method to write an object as a primitive or as an object
458458
* @param s the object to write
459459
* @param out the output (normally a stream) to write it to
460-
* @param allowSerializable true if we allow {@link Serializable} objects
461-
* @throws IOException from write primitives
462460
* @throws MessageFormatException if s is not a recognised type for writing
463461
* @throws NullPointerException if s is null
464462
*/
465-
private static final void writePrimitiveData(Object s, RMQByteArrayOutputStream out) throws JMSException {
463+
private static void writePrimitiveData(Object s, RMQByteArrayOutputStream out) throws JMSException {
466464
if(s==null) {
467465
throw new NullPointerException();
468466
} else if (s instanceof Boolean) {
469-
out.writeBoolean(((Boolean) s).booleanValue());
467+
out.writeBoolean((Boolean) s);
470468
} else if (s instanceof Byte) {
471-
out.writeByte(((Byte) s).byteValue());
469+
out.writeByte((Byte) s);
472470
} else if (s instanceof Short) {
473-
out.writeShort((((Short) s).shortValue()));
471+
out.writeShort(((Short) s));
474472
} else if (s instanceof Integer) {
475-
out.writeInt(((Integer) s).intValue());
473+
out.writeInt((Integer) s);
476474
} else if (s instanceof Long) {
477-
out.writeLong(((Long) s).longValue());
475+
out.writeLong((Long) s);
478476
} else if (s instanceof Float) {
479-
out.writeFloat(((Float) s).floatValue());
477+
out.writeFloat((Float) s);
480478
} else if (s instanceof Double) {
481-
out.writeDouble(((Double) s).doubleValue());
479+
out.writeDouble((Double) s);
482480
} else if (s instanceof String) {
483481
out.writeUTF((String) s);
484482
} else if (s instanceof Character) {
485-
out.writeChar(((Character) s).charValue());
486-
} else if (s instanceof Character) {
487-
out.writeChar(((Character) s).charValue());
483+
out.writeChar((Character) s);
488484
} else if (s instanceof byte[]) {
489485
out.write((byte[])s, 0, ((byte[]) s).length);
490486
} else
@@ -504,55 +500,55 @@ private static abstract class Bits { // prevent ourselves creating an instance
504500
* given offsets.
505501
*/
506502

507-
public static final int NUM_BYTES_IN_BOOLEAN = 1;
508-
public static boolean getBoolean(byte[] b, int off) {
503+
static final int NUM_BYTES_IN_BOOLEAN = 1;
504+
static boolean getBoolean(byte[] b, int off) {
509505
return b[off] != 0;
510506
}
511507

512-
public static final int NUM_BYTES_IN_CHAR = 2;
513-
public static char getChar(byte[] b, int off) {
514-
return (char) (((b[off + 1] & 0xFF) << 0) +
515-
((b[off + 0]) << 8));
508+
static final int NUM_BYTES_IN_CHAR = 2;
509+
static char getChar(byte[] b, int off) {
510+
return (char) (((b[off + 1] & 0xFF)) +
511+
((b[off]) << 8));
516512
}
517513

518-
public static final int NUM_BYTES_IN_SHORT = 2;
519-
public static short getShort(byte[] b, int off) {
520-
return (short) (((b[off + 1] & 0xFF) << 0) +
521-
((b[off + 0]) << 8));
514+
static final int NUM_BYTES_IN_SHORT = 2;
515+
static short getShort(byte[] b, int off) {
516+
return (short) (((b[off + 1] & 0xFF)) +
517+
((b[off]) << 8));
522518
}
523519

524-
public static final int NUM_BYTES_IN_INT = 4;
525-
public static int getInt(byte[] b, int off) {
526-
return ((b[off + 3] & 0xFF) << 0) +
520+
static final int NUM_BYTES_IN_INT = 4;
521+
static int getInt(byte[] b, int off) {
522+
return ((b[off + 3] & 0xFF)) +
527523
((b[off + 2] & 0xFF) << 8) +
528524
((b[off + 1] & 0xFF) << 16) +
529-
((b[off + 0]) << 24);
525+
((b[off]) << 24);
530526
}
531527

532-
public static final int NUM_BYTES_IN_FLOAT = 4;
533-
public static float getFloat(byte[] b, int off) {
528+
static final int NUM_BYTES_IN_FLOAT = 4;
529+
static float getFloat(byte[] b, int off) {
534530
return Float.intBitsToFloat(getInt(b, off));
535531
}
536532

537-
public static final int NUM_BYTES_IN_LONG = 8;
538-
public static long getLong(byte[] b, int off) {
539-
return ((b[off + 7] & 0xFFL) << 0) +
533+
static final int NUM_BYTES_IN_LONG = 8;
534+
static long getLong(byte[] b, int off) {
535+
return ((b[off + 7] & 0xFFL)) +
540536
((b[off + 6] & 0xFFL) << 8) +
541537
((b[off + 5] & 0xFFL) << 16) +
542538
((b[off + 4] & 0xFFL) << 24) +
543539
((b[off + 3] & 0xFFL) << 32) +
544540
((b[off + 2] & 0xFFL) << 40) +
545541
((b[off + 1] & 0xFFL) << 48) +
546-
(((long) b[off + 0]) << 56);
542+
(((long) b[off]) << 56);
547543
}
548544

549-
public static final int NUM_BYTES_IN_DOUBLE = 8;
550-
public static double getDouble(byte[] b, int off) {
545+
static final int NUM_BYTES_IN_DOUBLE = 8;
546+
static double getDouble(byte[] b, int off) {
551547
return Double.longBitsToDouble(getLong(b, off));
552548
}
553549
}
554550

555-
public static final RMQMessage recreate(BytesMessage msg) throws JMSException {
551+
public static RMQMessage recreate(BytesMessage msg) throws JMSException {
556552
msg.reset();
557553
long bodyLength = msg.getBodyLength();
558554
int bodySize = (int) Math.min(Math.max(0L, bodyLength), Integer.MAX_VALUE);

src/main/java/com/rabbitmq/jms/client/message/RMQMapMessage.java

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public boolean getBoolean(String name) throws JMSException {
3434
if (o == null)
3535
return false;
3636
else if (o instanceof Boolean)
37-
return ((Boolean) o).booleanValue();
37+
return (Boolean) o;
3838
else if (o instanceof String)
3939
return Boolean.parseBoolean((String) o);
4040
else
@@ -47,7 +47,7 @@ public byte getByte(String name) throws JMSException {
4747
if (o == null)
4848
throw new NumberFormatException(String.format(UNABLE_TO_CAST, o, "byte"));
4949
else if (o instanceof Byte)
50-
return ((Byte) o).byteValue();
50+
return (Byte) o;
5151
else if (o instanceof String)
5252
return Byte.parseByte((String) o);
5353
else
@@ -60,9 +60,9 @@ public short getShort(String name) throws JMSException {
6060
if (o == null)
6161
throw new NumberFormatException(String.format(UNABLE_TO_CAST, o, "short"));
6262
else if (o instanceof Byte)
63-
return ((Byte) o).byteValue();
63+
return (Byte) o;
6464
else if (o instanceof Short)
65-
return ((Short) o).shortValue();
65+
return (Short) o;
6666
else if (o instanceof String)
6767
return Short.parseShort((String) o);
6868
else
@@ -75,7 +75,7 @@ public char getChar(String name) throws JMSException {
7575
if (o == null)
7676
throw new NumberFormatException(String.format(UNABLE_TO_CAST, o, "char"));
7777
else if (o instanceof Character)
78-
return ((Character) o).charValue();
78+
return (Character) o;
7979
else
8080
throw new MessageFormatException(String.format(UNABLE_TO_CAST, o, "char"));
8181
}
@@ -86,11 +86,11 @@ public int getInt(String name) throws JMSException {
8686
if (o == null)
8787
throw new NumberFormatException(String.format(UNABLE_TO_CAST, o, "int"));
8888
else if (o instanceof Byte)
89-
return ((Byte) o).byteValue();
89+
return (Byte) o;
9090
else if (o instanceof Short)
91-
return ((Short) o).shortValue();
91+
return (Short) o;
9292
else if (o instanceof Integer)
93-
return ((Integer) o).intValue();
93+
return (Integer) o;
9494
else if (o instanceof String)
9595
return Integer.parseInt((String) o);
9696
else
@@ -103,13 +103,13 @@ public long getLong(String name) throws JMSException {
103103
if (o == null)
104104
throw new NumberFormatException(String.format(UNABLE_TO_CAST, o, "long"));
105105
else if (o instanceof Byte)
106-
return ((Byte) o).byteValue();
106+
return (Byte) o;
107107
else if (o instanceof Short)
108-
return ((Short) o).shortValue();
108+
return (Short) o;
109109
else if (o instanceof Integer)
110-
return ((Integer) o).intValue();
110+
return (Integer) o;
111111
else if (o instanceof Long)
112-
return ((Long) o).longValue();
112+
return (Long) o;
113113
else if (o instanceof String)
114114
return Long.parseLong((String) o);
115115
else
@@ -122,7 +122,7 @@ public float getFloat(String name) throws JMSException {
122122
if (o == null)
123123
throw new NumberFormatException(String.format(UNABLE_TO_CAST, o, "float"));
124124
else if (o instanceof Float) {
125-
return ((Float) o).floatValue();
125+
return (Float) o;
126126
} else if (o instanceof String)
127127
return Float.parseFloat((String) o);
128128
else
@@ -135,9 +135,9 @@ public double getDouble(String name) throws JMSException {
135135
if (o == null)
136136
throw new NumberFormatException(String.format(UNABLE_TO_CAST, o, "double"));
137137
else if (o instanceof Float)
138-
return ((Float) o).floatValue();
138+
return (Float) o;
139139
else if (o instanceof Double) {
140-
return ((Double) o).doubleValue();
140+
return (Double) o;
141141
} else if (o instanceof String)
142142
return Double.parseDouble((String) o);
143143
else
@@ -263,8 +263,8 @@ public void setBytes(String name, byte[] value, int offset, int length) throws J
263263
@Override
264264
public void setObject(String name, Object value) throws JMSException {
265265
checkNotReadonlyBody();
266-
if (name==null && value==null) {
267-
} else if (value==null) {
266+
if (name == null && value == null) {
267+
} else if (value == null) {
268268
this.data.remove(name);
269269
} else if (!(value instanceof Serializable)) {
270270
throw new MessageFormatException(String.format(UNABLE_TO_CAST, value, Serializable.class.getName()));
@@ -335,25 +335,23 @@ private void writePrimitiveData(Object s, ObjectOutput out, boolean allowSeriali
335335
if(s==null) {
336336
throw new NullPointerException();
337337
} else if (s instanceof Boolean) {
338-
out.writeBoolean(((Boolean) s).booleanValue());
338+
out.writeBoolean((Boolean) s);
339339
} else if (s instanceof Byte) {
340-
out.writeByte(((Byte) s).byteValue());
340+
out.writeByte((Byte) s);
341341
} else if (s instanceof Short) {
342-
out.writeShort((((Short) s).shortValue()));
342+
out.writeShort(((Short) s));
343343
} else if (s instanceof Integer) {
344-
out.writeInt(((Integer) s).intValue());
344+
out.writeInt((Integer) s);
345345
} else if (s instanceof Long) {
346-
out.writeLong(((Long) s).longValue());
346+
out.writeLong((Long) s);
347347
} else if (s instanceof Float) {
348-
out.writeFloat(((Float) s).floatValue());
348+
out.writeFloat((Float) s);
349349
} else if (s instanceof Double) {
350-
out.writeDouble(((Double) s).doubleValue());
350+
out.writeDouble((Double) s);
351351
} else if (s instanceof String) {
352352
out.writeUTF((String) s);
353353
} else if (s instanceof Character) {
354-
out.writeChar(((Character) s).charValue());
355-
} else if (s instanceof Character) {
356-
out.writeChar(((Character) s).charValue());
354+
out.writeChar((Character) s);
357355
} else if (allowSerializable && s instanceof Serializable) {
358356
out.writeObject(s);
359357
} else if (s instanceof byte[]) {
@@ -372,15 +370,15 @@ protected void writeAmqpBody(ByteArrayOutputStream out) throws IOException {
372370
throw new UnsupportedOperationException();
373371
}
374372

375-
public static final RMQMessage recreate(MapMessage msg) throws JMSException {
373+
public static RMQMessage recreate(MapMessage msg) throws JMSException {
376374
RMQMapMessage rmqMMsg = new RMQMapMessage();
377375
RMQMessage.copyAttributes(rmqMMsg, msg);
378376

379377
copyMapObjects(rmqMMsg, msg);
380378
return rmqMMsg;
381379
}
382380

383-
private static final void copyMapObjects(RMQMapMessage rmqMsg, MapMessage msg) throws JMSException {
381+
private static void copyMapObjects(RMQMapMessage rmqMsg, MapMessage msg) throws JMSException {
384382
@SuppressWarnings("unchecked")
385383
Enumeration<String> mapNames = (Enumeration<String>) msg.getMapNames();
386384
while (mapNames.hasMoreElements()) {

src/main/java/com/rabbitmq/jms/client/message/RMQObjectMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ protected void writeAmqpBody(ByteArrayOutputStream out) throws IOException {
110110
throw new UnsupportedOperationException();
111111
}
112112

113-
public static final RMQMessage recreate(ObjectMessage msg) throws JMSException {
113+
public static RMQMessage recreate(ObjectMessage msg) throws JMSException {
114114
RMQObjectMessage rmqOMsg = new RMQObjectMessage();
115115
RMQMessage.copyAttributes(rmqOMsg, msg);
116116

0 commit comments

Comments
 (0)