![JAR search and dependency download from the Maven repository](/logo.png)
com.espertech.esper.avro.getter.AvroEventBeanGetterSimpleDynamic Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of esper-avro Show documentation
Show all versions of esper-avro Show documentation
Complex event processing and event series analysis component
The newest version!
/*
***************************************************************************************
* Copyright (C) 2006 EsperTech, Inc. All rights reserved. *
* http://www.espertech.com/esper *
* http://www.espertech.com *
* ---------------------------------------------------------------------------------- *
* The software in this package is published under the terms of the GPL license *
* a copy of which has been included with this distribution in the license.txt file. *
***************************************************************************************
*/
package com.espertech.esper.avro.getter;
import com.espertech.esper.avro.core.AvroEventPropertyGetter;
import com.espertech.esper.client.EventBean;
import com.espertech.esper.client.PropertyAccessException;
import com.espertech.esper.codegen.base.CodegenClassScope;
import com.espertech.esper.codegen.base.CodegenMethodScope;
import com.espertech.esper.codegen.model.expression.CodegenExpression;
import com.espertech.esper.codegen.model.expression.CodegenExpressionBuilder;
import org.apache.avro.generic.GenericData;
import static com.espertech.esper.codegen.model.expression.CodegenExpressionBuilder.*;
public class AvroEventBeanGetterSimpleDynamic implements AvroEventPropertyGetter {
private final String propertyName;
public AvroEventBeanGetterSimpleDynamic(String propertyName) {
this.propertyName = propertyName;
}
public Object getAvroFieldValue(GenericData.Record record) throws PropertyAccessException {
return record.get(propertyName);
}
public Object get(EventBean theEvent) {
return getAvroFieldValue((GenericData.Record) theEvent.getUnderlying());
}
public boolean isExistsProperty(EventBean eventBean) {
return isExistsPropertyAvro((GenericData.Record) eventBean.getUnderlying());
}
public boolean isExistsPropertyAvro(GenericData.Record record) {
return record.getSchema().getField(propertyName) != null;
}
public Object getFragment(EventBean obj) {
return null;
}
public Object getAvroFragment(GenericData.Record record) {
return null;
}
public CodegenExpression eventBeanGetCodegen(CodegenExpression beanExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) {
return underlyingGetCodegen(castUnderlying(GenericData.Record.class, beanExpression), codegenMethodScope, codegenClassScope);
}
public CodegenExpression eventBeanExistsCodegen(CodegenExpression beanExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) {
return underlyingExistsCodegen(castUnderlying(GenericData.Record.class, beanExpression), codegenMethodScope, codegenClassScope);
}
public CodegenExpression eventBeanFragmentCodegen(CodegenExpression beanExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) {
return constantNull();
}
public CodegenExpression underlyingGetCodegen(CodegenExpression underlyingExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) {
return CodegenExpressionBuilder.exprDotMethod(underlyingExpression, "get", constant(propertyName));
}
public CodegenExpression underlyingExistsCodegen(CodegenExpression underlyingExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) {
return notEqualsNull(exprDotMethodChain(underlyingExpression).add("getSchema").add("getField", constant(propertyName)));
}
public CodegenExpression underlyingFragmentCodegen(CodegenExpression underlyingExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) {
return constantNull();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy