com.espertech.esper.avro.getter.AvroEventBeanGetterNestedPoly 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.event.EventPropertyGetterSPI;
import org.apache.avro.generic.GenericData;
import static com.espertech.esper.avro.getter.AvroEventBeanGetterDynamicPoly.*;
import static com.espertech.esper.avro.getter.AvroEventBeanGetterDynamicPoly.getAvroFieldValuePoly;
import static com.espertech.esper.codegen.model.expression.CodegenExpressionBuilder.*;
public class AvroEventBeanGetterNestedPoly implements EventPropertyGetterSPI {
private final int top;
private final AvroEventPropertyGetter[] getters;
public AvroEventBeanGetterNestedPoly(int top, AvroEventPropertyGetter[] getters) {
this.top = top;
this.getters = getters;
}
public Object get(EventBean eventBean) throws PropertyAccessException {
GenericData.Record record = (GenericData.Record) eventBean.getUnderlying();
GenericData.Record inner = (GenericData.Record) record.get(top);
return getAvroFieldValuePoly(inner, getters);
}
public boolean isExistsProperty(EventBean eventBean) {
GenericData.Record record = (GenericData.Record) eventBean.getUnderlying();
GenericData.Record inner = (GenericData.Record) record.get(top);
return getAvroFieldValuePolyExists(inner, getters);
}
public Object getFragment(EventBean eventBean) throws PropertyAccessException {
GenericData.Record record = (GenericData.Record) eventBean.getUnderlying();
GenericData.Record inner = (GenericData.Record) record.get(top);
return getAvroFieldFragmentPoly(inner, getters);
}
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 underlyingFragmentCodegen(castUnderlying(GenericData.Record.class, beanExpression), codegenMethodScope, codegenClassScope);
}
public CodegenExpression underlyingGetCodegen(CodegenExpression underlyingExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) {
return localMethod(getAvroFieldValuePolyCodegen(codegenMethodScope, codegenClassScope, getters), cast(GenericData.Record.class, exprDotMethod(underlyingExpression, "get", constant(top))));
}
public CodegenExpression underlyingExistsCodegen(CodegenExpression underlyingExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) {
return localMethod(getAvroFieldValuePolyExistsCodegen(codegenMethodScope, codegenClassScope, getters), cast(GenericData.Record.class, exprDotMethod(underlyingExpression, "get", constant(top))));
}
public CodegenExpression underlyingFragmentCodegen(CodegenExpression underlyingExpression, CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) {
return localMethod(getAvroFieldFragmentPolyCodegen(codegenMethodScope, codegenClassScope, getters), cast(GenericData.Record.class, exprDotMethod(underlyingExpression, "get", constant(top))));
}
}