public Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context) { EventBean event = eventsPerStream[streamId]; if (event == null) { return null; } return getter.get(event); }
public Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context) { EventBean theEvent = eventsPerStream[streamId]; if (theEvent == null) { return null; } Object event = getterFragment.getFragment(theEvent); if (!(event instanceof EventBean)) { return null; } return getterTimestamp.get((EventBean) event); }
public boolean isExistsProperty(EventBean eventBean) { if (!getterChain[0].isExistsProperty(eventBean)) { return false; } Object result = getterChain[0].get(eventBean); return handleIsExistsTrailingChain(result); }
public CodegenExpression evaluateEventGetROCollectionScalarCodegen(CodegenMethodScope codegenMethodScope, ExprEnumerationGivenEventSymbol symbols, CodegenClassScope codegenClassScope) { if (JavaClassHelper.isImplementsInterface(getterReturnType, Collection.class)) { return getter.eventBeanGetCodegen(symbols.getAddEvent(codegenMethodScope), codegenMethodScope, codegenClassScope); } CodegenMethod method = codegenMethodScope.makeChild(Collection.class, PropertyDotScalarIterable.class, codegenClassScope); method.getBlock().declareVar(getterReturnType, "result", CodegenLegoCast.castSafeFromObjectType(Iterable.class, getter.eventBeanGetCodegen(symbols.getAddEvent(method), codegenMethodScope, codegenClassScope))) .ifRefNullReturnNull("result") .methodReturn(staticMethod(CollectionUtil.class, "iterableToCollection", ref("result"))); return localMethod(method); }
public static CodegenMethod from(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope, Class expectedUnderlyingType, EventPropertyGetterSPI innerGetter, AccessType accessType, Class generator) { CodegenMethod methodNode = codegenMethodScope.makeChild(accessType == AccessType.EXISTS ? boolean.class : Object.class, generator, codegenClassScope).addParam(Object.class, "value"); CodegenBlock block = methodNode.getBlock() .ifNotInstanceOf("value", expectedUnderlyingType) .ifInstanceOf("value", EventBean.class) .declareVarWCast(EventBean.class, "bean", "value"); if (accessType == AccessType.GET) { block = block.blockReturn(innerGetter.eventBeanGetCodegen(ref("bean"), codegenMethodScope, codegenClassScope)); } else if (accessType == AccessType.EXISTS) { block = block.blockReturn(innerGetter.eventBeanExistsCodegen(ref("bean"), codegenMethodScope, codegenClassScope)); } else if (accessType == AccessType.FRAGMENT) { block = block.blockReturn(innerGetter.eventBeanFragmentCodegen(ref("bean"), codegenMethodScope, codegenClassScope)); } else { throw new UnsupportedOperationException("Invalid access type " + accessType); } block = block.blockReturn(constant(accessType == AccessType.EXISTS ? false : null)); CodegenExpression expression; if (accessType == AccessType.GET) { expression = innerGetter.underlyingGetCodegen(cast(expectedUnderlyingType, ref("value")), codegenMethodScope, codegenClassScope); } else if (accessType == AccessType.EXISTS) { expression = innerGetter.underlyingExistsCodegen(cast(expectedUnderlyingType, ref("value")), codegenMethodScope, codegenClassScope); } else if (accessType == AccessType.FRAGMENT) { expression = innerGetter.underlyingFragmentCodegen(cast(expectedUnderlyingType, ref("value")), codegenMethodScope, codegenClassScope); } else { throw new UnsupportedOperationException("Invalid access type " + accessType); } block.methodReturn(expression); return methodNode; }
EventPropertyGetterSPI getter = getterChain[i]; CodegenBlock blockBean = block.ifInstanceOf("result", EventBean.class); blockBean.assignRef("result", getter.eventBeanGetCodegen(cast(EventBean.class, ref("result")), codegenMethodScope, codegenClassScope)); .assignRef("result", getter.underlyingGetCodegen(cast(type, ref("result")), codegenMethodScope, codegenClassScope)) .blockEnd(); } else if (getter instanceof MapEventPropertyGetter) { blockBean.ifElse() .ifRefNotTypeReturnConst("result", Map.class, false) .assignRef("result", getter.underlyingGetCodegen(cast(Map.class, ref("result")), codegenMethodScope, codegenClassScope)) .blockEnd(); } else { if (getter instanceof BeanEventPropertyGetter) { BeanEventPropertyGetter beanGetter = (BeanEventPropertyGetter) getter; return block.methodReturn(getter.underlyingExistsCodegen(cast(beanGetter.getTargetType(), ref("result")), codegenMethodScope, codegenClassScope)); } else if (getter instanceof MapEventPropertyGetter) { return block.methodReturn(getter.underlyingExistsCodegen(cast(Map.class, ref("result")), codegenMethodScope, codegenClassScope)); } else { block.ifInstanceOf("result", EventBean.class) .blockReturn(getter.eventBeanExistsCodegen(cast(EventBean.class, ref("result")), codegenMethodScope, codegenClassScope)); return block.methodReturn(constantFalse());
public CodegenExpression evaluateCodegen(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(Long.class, ExprEvaluatorStreamDTPropFragment.class, codegenClassScope); CodegenExpressionRef refEPS = exprSymbol.getAddEPS(methodNode); methodNode.getBlock() .declareVar(EventBean.class, "theEvent", arrayAtIndex(refEPS, constant(streamId))) .ifRefNullReturnNull("theEvent") .declareVar(Object.class, "event", getterFragment.eventBeanFragmentCodegen(ref("theEvent"), methodNode, codegenClassScope)) .ifCondition(not(instanceOf(ref("event"), EventBean.class))) .blockReturn(constantNull()) .methodReturn(CodegenLegoCast.castSafeFromObjectType(Long.class, getterTimestamp.eventBeanGetCodegen(cast(EventBean.class, ref("event")), methodNode, codegenClassScope))); return localMethod(methodNode); }
private CodegenExpression codegenGet(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { if (returnType == null) { return constantNull(); } Class castTargetType = getCodegenReturnType(requiredType); boolean useUnderlying = exprSymbol.isAllowUnderlyingReferences() && !identNode.getResolvedPropertyName().contains("?") && !(eventType instanceof WrapperEventType) && !(eventType instanceof VariantEventType); if (useUnderlying && !optionalEvent) { CodegenExpressionRef underlying = exprSymbol.getAddRequiredUnderlying(codegenMethodScope, streamNum, eventType, false); return CodegenLegoCast.castSafeFromObjectType(castTargetType, propertyGetter.underlyingGetCodegen(underlying, codegenMethodScope, codegenClassScope)); } CodegenMethod method = codegenMethodScope.makeChild(castTargetType, this.getClass(), codegenClassScope); CodegenBlock block = method.getBlock(); if (useUnderlying) { CodegenExpressionRef underlying = exprSymbol.getAddRequiredUnderlying(method, streamNum, eventType, true); block.ifRefNullReturnNull(underlying) .methodReturn(CodegenLegoCast.castSafeFromObjectType(castTargetType, propertyGetter.underlyingGetCodegen(underlying, method, codegenClassScope))); } else { CodegenExpressionRef refEPS = exprSymbol.getAddEPS(method); method.getBlock().declareVar(EventBean.class, "event", arrayAtIndex(refEPS, constant(streamNum))); if (optionalEvent) { block.ifRefNullReturnNull("event"); } block.methodReturn(CodegenLegoCast.castSafeFromObjectType(castTargetType, propertyGetter.eventBeanGetCodegen(ref("event"), method, codegenClassScope))); } return localMethod(method); }
private CodegenMethod getFragmentCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.makeChild(Object.class, this.getClass(), codegenClassScope).addParam(EventBean.class, "theEvent").getBlock() .declareVarWCast(DecoratingEventBean.class, "wrapperEvent", "theEvent") .declareVar(EventBean.class, "wrappedEvent", exprDotMethod(ref("wrapperEvent"), "getUnderlyingEvent")) .ifRefNullReturnNull("wrappedEvent") .methodReturn(underlyingGetter.eventBeanFragmentCodegen(ref("wrappedEvent"), codegenMethodScope, codegenClassScope)); }
public EventBean evaluateGetEventBean(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context) { EventBean event = eventsPerStream[streamId]; if (event == null) { return null; } return (EventBean) getter.getFragment(event); }
private CodegenMethod isMapExistsPropertyCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) throws PropertyAccessException { return codegenMethodScope.makeChild(boolean.class, this.getClass(), codegenClassScope).addParam(Map.class, "map").getBlock() .ifConditionReturnConst(getterChain[0].underlyingExistsCodegen(ref("map"), codegenMethodScope, codegenClassScope), false) .declareVar(Object.class, "result", getterChain[0].underlyingGetCodegen(ref("map"), codegenMethodScope, codegenClassScope)) .methodReturn(localMethod(handleIsExistsTrailingChainCodegen(codegenMethodScope, codegenClassScope), ref("result"))); }
private CodegenMethod getCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) throws PropertyAccessException { return codegenMethodScope.makeChild(Object.class, this.getClass(), codegenClassScope).addParam(Node.class, "node").getBlock() .declareVar(Object.class, "value", getter.underlyingGetCodegen(ref("node"), codegenMethodScope, codegenClassScope)) .methodReturn(staticMethod(this.getClass(), "getXPathNodeListWCheck", ref("value"), constant(index))); }
/** * Returns true if the property exists, or false if not. * * @param eventsPerStream each stream's events * @param isNewData if the stream represents insert or remove stream * @return true if the property exists, false if not */ public boolean evaluatePropertyExists(EventBean[] eventsPerStream, boolean isNewData) { EventBean theEvent = eventsPerStream[streamNum]; if (theEvent == null) { return false; } return propertyGetter.isExistsProperty(theEvent); }
private CodegenMethod getFragmentCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { return codegenMethodScope.makeChild(Object.class, this.getClass(), codegenClassScope).addParam(EventBean.class, "theEvent").getBlock() .declareVarWCast(DecoratingEventBean.class, "wrapperEvent", "theEvent") .declareVar(Map.class, "map", exprDotMethod(ref("wrapperEvent"), "getDecoratingProperties")) .methodReturn(mapGetter.underlyingFragmentCodegen(ref("map"), codegenMethodScope, codegenClassScope)); }
public CodegenExpression evaluateCodegenUninstrumented(Class requiredType, CodegenMethodScope codegenMethodScope, ExprForgeCodegenSymbol exprSymbol, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(Boolean.class, this.getClass(), codegenClassScope); CodegenExpressionRef refEPS = exprSymbol.getAddEPS(methodNode); methodNode.getBlock() .declareVar(EventBean.class, "event", arrayAtIndex(refEPS, constant(identNode.getStreamId()))) .ifRefNullReturnNull("event") .methodReturn(identNode.getExprEvaluatorIdent().getGetter().eventBeanExistsCodegen(ref("event"), methodNode, codegenClassScope)); return localMethod(methodNode); }
public CodegenExpression evaluateEventGetROCollectionScalarCodegen(CodegenMethodScope codegenMethodScope, ExprEnumerationGivenEventSymbol symbols, CodegenClassScope codegenClassScope) { CodegenMethod methodNode = codegenMethodScope.makeChild(Collection.class, PropertyDotScalarCollection.class, codegenClassScope); methodNode.getBlock().methodReturn(CodegenLegoCast.castSafeFromObjectType(Collection.class, getter.eventBeanGetCodegen(symbols.getAddEvent(methodNode), codegenMethodScope, codegenClassScope))); return localMethod(methodNode); }
CodegenExpression fragment = ((EventTypeSPI) eventTypes[underlyingStreamNumber]).getGetterSPI(unnamedStreams.get(0).getStreamSelected().getStreamName()).eventBeanFragmentCodegen(ref("eventBean"), methodNode, codegenClassScope); block.declareVar(EventBean.class, "eventBean", arrayAtIndex(refEPS, constant(underlyingStreamNumber))) .declareVar(EventBean.class, "theEvent", cast(EventBean.class, fragment)); } else if (underlyingPropertyEventGetter != null) { block.declareVar(EventBean.class, "theEvent", constantNull()) .declareVar(Object.class, "value", underlyingPropertyEventGetter.eventBeanGetCodegen(arrayAtIndex(refEPS, constant(underlyingStreamNumber)), methodNode, codegenClassScope)) .ifRefNotNull("value") .assignRef("theEvent", exprDotMethod(eventBeanFactory, "adapterForTypedBean", ref("value"), wrapperUndType))
private CodegenMethod handleGetterTrailingChainCodegen(CodegenMethodScope codegenMethodScope, CodegenClassScope codegenClassScope) { CodegenBlock block = codegenMethodScope.makeChild(Object.class, this.getClass(), codegenClassScope).addParam(Object.class, "result").getBlock(); for (int i = 1; i < getterChain.length; i++) { block.ifRefNullReturnNull("result"); EventPropertyGetterSPI getter = getterChain[i]; CodegenBlock blockBean = block.ifInstanceOf("result", EventBean.class); blockBean.assignRef("result", getter.eventBeanGetCodegen(cast(EventBean.class, ref("result")), codegenMethodScope, codegenClassScope)); if (getter instanceof BeanEventPropertyGetter) { Class type = ((BeanEventPropertyGetter) getter).getTargetType(); blockBean.ifElse() .assignRef("result", getter.underlyingGetCodegen(cast(type, ref("result")), codegenMethodScope, codegenClassScope)) .blockEnd(); } else if (getter instanceof MapEventPropertyGetter) { blockBean.ifElse() .ifRefNotTypeReturnConst("result", Map.class, null) .assignRef("result", getter.underlyingGetCodegen(cast(Map.class, ref("result")), codegenMethodScope, codegenClassScope)) .blockEnd(); } else { blockBean.ifElse().blockReturn(constantNull()); } } return block.methodReturn(ref("result")); } }
public CodegenExpression make(CodegenMethodScope parent, SAIFFInitializeSymbol symbols, CodegenClassScope classScope) { CodegenMethod method = parent.makeChild(ContainedEventEvalGetter.class, this.getClass(), classScope); CodegenExpressionNewAnonymousClass anonymousClass = newAnonymousClass(method.getBlock(), EventPropertyFragmentGetter.class); CodegenMethod getFragment = CodegenMethod.makeParentNode(Object.class, this.getClass(), classScope).addParam(EventBean.class, "event"); anonymousClass.addMethod("getFragment", getFragment); getFragment.getBlock().methodReturn(getter.eventBeanFragmentCodegen(ref("event"), getFragment, classScope)); method.getBlock().methodReturn(newInstance(ContainedEventEvalGetter.class, anonymousClass)); return localMethod(method); } }
public Object evaluate(EventBean[] eventsPerStream, boolean isNewData, ExprEvaluatorContext context) { EventBean event = eventsPerStream[streamId]; if (event == null) { return null; } return getter.getFragment(event); }