@Test public void testEvaluate() { Map<String, Object> values = new HashMap<String, Object>(); values.put("a", 1); values.put("b", 1.0f); values.put("c", "3"); IEvent event = new TupleEvent("stream", "schemName", values, eventTypeMng); PropertyValueExpression propertyValueExpressionA = new PropertyValueExpression("a", Integer.class); Object expectedResultA = propertyValueExpressionA.evaluate(event); PropertyValueExpression propertyValueExpressionB = new PropertyValueExpression("b", Float.class); Object expectedResultB = propertyValueExpressionB.evaluate(event); PropertyValueExpression propertyValueExpressionC = new PropertyValueExpression("c", String.class); Object expectedResultC = propertyValueExpressionC.evaluate(event); assertEquals(expectedResultA, 1); assertEquals(expectedResultB, 1.0f); assertEquals(expectedResultC, "3"); }
@Override public Object evaluate(IEvent theEvent) { if (null == theEvent) { String msg = "Event is null!"; LOG.error(msg); throw new RuntimeException(msg); } if (propertyIndex == -1) { propertyIndex = theEvent.getIndexByPropertyName(getPropertyName()); } return theEvent.getValue(propertyIndex); }
PropertyValueExpression extends PropertyBasedExpression { @Override public Object evaluate(IEvent theEvent) { if (null == theEvent) { String msg = "Event is null!"; LOG.error(msg); throw new RuntimeException(msg); } if (propertyIndex == -1) { propertyIndex = theEvent.getIndexByPropertyName(getPropertyName()); } return theEvent.getValue(propertyIndex); } }
PropertyValueExpression extends PropertyBasedExpression { @Override public Object evaluate(IEvent theEvent) { if (null == theEvent) { String msg = "Event is null!"; LOG.error(msg); throw new RuntimeException(msg); } if (propertyIndex == -1) { propertyIndex = theEvent.getIndexByPropertyName(getPropertyName()); } return theEvent.getValue(propertyIndex); } PropertyValueExpression(int id, String propertyName, Class< ? > type);  PropertyValueExpression(String propertyName, Class< ? > type); }
PropertyValueExpression extends PropertyBasedExpression { @Override public Object evaluate(IEvent theEvent) { if (null == theEvent) { String msg = "Event is null!"; LOG.error(msg); throw new RuntimeException(msg); } if (propertyIndex == -1) { propertyIndex = theEvent.getIndexByPropertyName(getPropertyName()); } return theEvent.getValue(propertyIndex); } PropertyValueExpression(int id, String propertyName, Class< ? > type);  PropertyValueExpression(String propertyName, Class< ? > type); final int getStreamIndex(); void setStreamIndex(int streamIndex); @Override Object evaluate(IEvent theEvent); @Override Object evaluate(IEvent[] eventsPerStream); @Override Class< ? > getType(); }
PropertyValueExpression extends PropertyBasedExpression { @Override public Object evaluate(IEvent theEvent) { if (null == theEvent) { String msg = "Event is null!"; LOG.error(msg); throw new RuntimeException(msg); } if (propertyIndex == -1) { propertyIndex = theEvent.getIndexByPropertyName(getPropertyName()); } return theEvent.getValue(propertyIndex); } PropertyValueExpression(int id, String propertyName, Class< ? > type);  PropertyValueExpression(String propertyName, Class< ? > type); final int getStreamIndex(); void setStreamIndex(int streamIndex); @Override Object evaluate(IEvent theEvent); @Override Object evaluate(IEvent[] eventsPerStream); @Override Class< ? > getType();  }