Modernize code for diamond, isEmpty & pattern matching
This commit is contained in:
@@ -31,6 +31,7 @@ import org.springframework.messaging.MessagingException;
|
||||
* @author Mark Fisher
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class ByteStreamReadingMessageSource extends AbstractMessageSource<byte[]> {
|
||||
|
||||
@@ -47,8 +48,8 @@ public class ByteStreamReadingMessageSource extends AbstractMessageSource<byte[]
|
||||
}
|
||||
|
||||
public ByteStreamReadingMessageSource(InputStream stream, int bufferSize) {
|
||||
if (stream instanceof BufferedInputStream) {
|
||||
this.stream = (BufferedInputStream) stream;
|
||||
if (stream instanceof BufferedInputStream bufferedInputStream) {
|
||||
this.stream = bufferedInputStream;
|
||||
}
|
||||
else if (bufferSize > 0) {
|
||||
this.stream = new BufferedInputStream(stream, bufferSize);
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.springframework.messaging.MessagingException;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class ByteStreamWritingMessageHandler extends AbstractMessageHandler {
|
||||
|
||||
@@ -57,11 +58,11 @@ public class ByteStreamWritingMessageHandler extends AbstractMessageHandler {
|
||||
protected void handleMessageInternal(Message<?> message) {
|
||||
Object payload = message.getPayload();
|
||||
try {
|
||||
if (payload instanceof String) {
|
||||
this.stream.write(((String) payload).getBytes());
|
||||
if (payload instanceof String string) {
|
||||
this.stream.write(string.getBytes());
|
||||
}
|
||||
else if (payload instanceof byte[]) {
|
||||
this.stream.write((byte[]) payload);
|
||||
else if (payload instanceof byte[] bytes) {
|
||||
this.stream.write(bytes);
|
||||
}
|
||||
else {
|
||||
throw new MessagingException(this.getClass().getSimpleName() +
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.util.Assert;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Christian Tzolov
|
||||
* @author Ngoc Nhan
|
||||
*/
|
||||
public class CharacterStreamReadingMessageSource extends AbstractMessageSource<String>
|
||||
implements ApplicationEventPublisherAware {
|
||||
@@ -92,8 +93,8 @@ public class CharacterStreamReadingMessageSource extends AbstractMessageSource<S
|
||||
*/
|
||||
public CharacterStreamReadingMessageSource(Reader reader, int bufferSize, boolean blockToDetectEOF) {
|
||||
Assert.notNull(reader, "reader must not be null");
|
||||
if (reader instanceof BufferedReader) {
|
||||
this.reader = (BufferedReader) reader;
|
||||
if (reader instanceof BufferedReader bufferedReader) {
|
||||
this.reader = bufferedReader;
|
||||
}
|
||||
else if (bufferSize > 0) {
|
||||
this.reader = new BufferedReader(reader, bufferSize);
|
||||
|
||||
Reference in New Issue
Block a user