mirror of
https://github.com/alibaba/canal.git
synced 2026-11-04 00:30:15 +08:00
= code cleanup
- for loop replaceable with enhanced 'for' loop - using diamond in generic type - collapse try catch exception - using try-with-resource - using List#sort instead of Collections#sort - replaced lambda with method reference - using native compare method to compare numbers - using switch instead of if for in ESSyncUtil
This commit is contained in:
@@ -18,24 +18,24 @@ public class Message implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1234034768477580009L;
|
||||
private long id;
|
||||
private List<CanalEntry.Entry> entries = new ArrayList<CanalEntry.Entry>();
|
||||
private List<CanalEntry.Entry> entries = new ArrayList<>();
|
||||
// row data for performance, see:
|
||||
// https://github.com/alibaba/canal/issues/726
|
||||
private boolean raw = true;
|
||||
private List<ByteString> rawEntries = new ArrayList<ByteString>();
|
||||
private List<ByteString> rawEntries = new ArrayList<>();
|
||||
|
||||
public Message(long id, List<Entry> entries){
|
||||
this.id = id;
|
||||
this.entries = entries == null ? new ArrayList<Entry>() : entries;
|
||||
this.entries = entries == null ? new ArrayList<>() : entries;
|
||||
this.raw = false;
|
||||
}
|
||||
|
||||
public Message(long id, boolean raw, List entries){
|
||||
this.id = id;
|
||||
if (raw) {
|
||||
this.rawEntries = entries == null ? new ArrayList<ByteString>() : entries;
|
||||
this.rawEntries = entries == null ? new ArrayList<>() : entries;
|
||||
} else {
|
||||
this.entries = entries == null ? new ArrayList<Entry>() : entries;
|
||||
this.entries = entries == null ? new ArrayList<>() : entries;
|
||||
}
|
||||
this.raw = raw;
|
||||
}
|
||||
|
||||
@@ -84,8 +84,8 @@ public class SecurityUtil {
|
||||
*/
|
||||
public static String byte2HexStr(byte[] b) {
|
||||
StringBuilder hs = new StringBuilder();
|
||||
for (int n = 0; n < b.length; n++) {
|
||||
String hex = (Integer.toHexString(b[n] & 0XFF));
|
||||
for (byte value : b) {
|
||||
String hex = (Integer.toHexString(value & 0XFF));
|
||||
if (hex.length() == 1) {
|
||||
hs.append("0" + hex);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user