StreamEvent implements Serializable { public StreamEvent() { } StreamEvent();  StreamEvent(String streamId, long timestamp, Object[] data);  StreamEvent(String streamId, long timestamp, Object[] data, String metaVersion); String getStreamId(); void setStreamId(String streamId); void setData(Object[] data); long getTimestamp(); void setTimestamp(long timestamp); String getMetaVersion(); void setMetaVersion(String metaVersion); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static StreamEventBuilder builder(); StreamEvent copy(); void copyFrom(StreamEvent event); Object[] getData(); Object[] getData(StreamDefinition streamDefinition, List<String> column); Object[] getData(StreamDefinition streamDefinition, String... column);  }
@Test public void testStreamEvent() { Object[] data = new Object[]{"namevalue", "hostvalue", "1", 10.0, 1, -0.2, "{\"name\":\"heap.COMMITTED\", \"Value\":\"175636480\"}", 4}; StreamEvent streamEvent = new StreamEvent("streamId", 1478667686971l, data); Assert.assertEquals("StreamEvent[stream=STREAMID,timestamp=2016-11-09 05:01:26,971,data=[namevalue,hostvalue,1,10.0,1,-0.2,{\"name\":\"heap.COMMITTED\", \"Value\":\"175636480\"},4],metaVersion=null]", streamEvent.toString()); streamEvent = new StreamEvent("streamId", 1478667686971l, data, "metaVersion"); Assert.assertEquals("StreamEvent[stream=STREAMID,timestamp=2016-11-09 05:01:26,971,data=[namevalue,hostvalue,1,10.0,1,-0.2,{\"name\":\"heap.COMMITTED\", \"Value\":\"175636480\"},4],metaVersion=metaVersion]", streamEvent.toString()); StreamEvent streamEventCopy = streamEvent.copy(); Assert.assertFalse(streamEventCopy == streamEvent); Assert.assertTrue(streamEventCopy.equals(streamEvent)); Assert.assertTrue(streamEventCopy.hashCode() == streamEvent.hashCode()); streamEventCopy.setMetaVersion(""); Assert.assertFalse(streamEventCopy == streamEvent); Assert.assertFalse(streamEventCopy.equals(streamEvent)); Assert.assertFalse(streamEventCopy.hashCode() == streamEvent.hashCode()); streamEventCopy.copyFrom(streamEvent); Assert.assertFalse(streamEventCopy == streamEvent); Assert.assertTrue(streamEventCopy.equals(streamEvent)); Assert.assertTrue(streamEventCopy.hashCode() == streamEvent.hashCode()); List<StreamColumn> streamColumns = new ArrayList<>(); streamColumns.add(new StreamColumn.Builder().name("name").type(StreamColumn.Type.STRING).build()); streamColumns.add(new StreamColumn.Builder().name("host").type(StreamColumn.Type.STRING).build()); streamColumns.add(new StreamColumn.Builder().name("flag").type(StreamColumn.Type.BOOL).build()); streamColumns.add(new StreamColumn.Builder().name("value").type(StreamColumn.Type.DOUBLE).build()); streamColumns.add(new StreamColumn.Builder().name("data").type(StreamColumn.Type.LONG).build()); streamColumns.add(new StreamColumn.Builder().name("salary").type(StreamColumn.Type.FLOAT).build()); streamColumns.add(new StreamColumn.Builder().name("object").type(StreamColumn.Type.OBJECT).build()); streamColumns.add(new StreamColumn.Builder().name("int").type(StreamColumn.Type.INT).build()); StreamDefinition streamDefinition = new StreamDefinition(); streamDefinition.setColumns(streamColumns); Object[] values = streamEvent.getData(streamDefinition, "int", "salary", "flag", "object"); Assert.assertEquals(4, values[0]); Assert.assertEquals(-0.2, values[1]); Assert.assertEquals("1", values[2]); Assert.assertEquals("{\"name\":\"heap.COMMITTED\", \"Value\":\"175636480\"}", values[3]); values = streamEvent.getData(streamDefinition, Arrays.asList("int", "data", "flag", "object")); Assert.assertEquals(4, values[0]); Assert.assertEquals(1, values[1]); Assert.assertEquals("1", values[2]); Assert.assertEquals("{\"name\":\"heap.COMMITTED\", \"Value\":\"175636480\"}", values[3]); }