From f5012286ae449e0b8b09cc8f8ad0d83ef15d0c82 Mon Sep 17 00:00:00 2001 From: Ben Osheroff Date: Sun, 22 Nov 2015 10:04:06 -0800 Subject: [PATCH] Move RowMap into its own file --- .../maxwell/MaxwellAbstractRowsEvent.java | 43 +--------------- src/main/java/com/zendesk/maxwell/RowMap.java | 49 +++++++++++++++++++ .../maxwell/MaxwellIntegrationTest.java | 2 - 3 files changed, 50 insertions(+), 44 deletions(-) create mode 100644 src/main/java/com/zendesk/maxwell/RowMap.java diff --git a/src/main/java/com/zendesk/maxwell/MaxwellAbstractRowsEvent.java b/src/main/java/com/zendesk/maxwell/MaxwellAbstractRowsEvent.java index efcba73fc..67dd5848b 100644 --- a/src/main/java/com/zendesk/maxwell/MaxwellAbstractRowsEvent.java +++ b/src/main/java/com/zendesk/maxwell/MaxwellAbstractRowsEvent.java @@ -197,47 +197,6 @@ public String toSQL() { return sql.toString(); } - class RowMap extends HashMap { - private final HashMap data; - - public RowMap() { - this.data = new HashMap(); - this.put("data", this.data); - } - - public void setRowType(String type) { - this.put("type", type); - } - - public void putData(String key, Object value) { - this.data.put(key, value); - } - - public void setTable(String name) { - this.put("table", name); - } - - public void setDatabase(String name) { - this.put("database", name); - } - - public void setTimestamp(Long l) { - this.put("ts", l); - } - - public void setXid(Long xid) { - this.put("xid", xid); - } - - public void setTXCommit() { - this.put("commit", true); - } - - public Object getData(String string) { - return this.data.get(string); - } - } - public List jsonMaps() { ArrayList list = new ArrayList<>(); Object value; @@ -306,7 +265,7 @@ private void rowMapToJSON(JsonGenerator g, RowMap map) throws IOException { g.writeBooleanField("commit", true); g.writeObjectFieldStart("data"); - for ( String key: map.data.keySet() ) { + for ( String key: map.dataKeySet() ) { Object data = map.getData(key); if ( data == null ) diff --git a/src/main/java/com/zendesk/maxwell/RowMap.java b/src/main/java/com/zendesk/maxwell/RowMap.java new file mode 100644 index 000000000..6c6e3d3aa --- /dev/null +++ b/src/main/java/com/zendesk/maxwell/RowMap.java @@ -0,0 +1,49 @@ +package com.zendesk.maxwell; + +import java.util.HashMap; +import java.util.Set; + +public class RowMap extends HashMap { + private final HashMap data; + + public RowMap() { + this.data = new HashMap(); + this.put("data", this.data); + } + + public void setRowType(String type) { + this.put("type", type); + } + + public void putData(String key, Object value) { + this.data.put(key, value); + } + + public void setTable(String name) { + this.put("table", name); + } + + public void setDatabase(String name) { + this.put("database", name); + } + + public void setTimestamp(Long l) { + this.put("ts", l); + } + + public void setXid(Long xid) { + this.put("xid", xid); + } + + public void setTXCommit() { + this.put("commit", true); + } + + public Object getData(String string) { + return this.data.get(string); + } + + public Set dataKeySet() { + return this.data.keySet(); + } +} diff --git a/src/test/java/com/zendesk/maxwell/MaxwellIntegrationTest.java b/src/test/java/com/zendesk/maxwell/MaxwellIntegrationTest.java index df693da43..4330d5353 100644 --- a/src/test/java/com/zendesk/maxwell/MaxwellIntegrationTest.java +++ b/src/test/java/com/zendesk/maxwell/MaxwellIntegrationTest.java @@ -16,8 +16,6 @@ import org.apache.commons.lang.StringUtils; import org.junit.Test; -import com.zendesk.maxwell.MaxwellAbstractRowsEvent.RowMap; - public class MaxwellIntegrationTest extends AbstractMaxwellTest { public static final TypeReference> MAP_STRING_OBJECT_REF = new TypeReference>() {};