visitor.visitEnumeration(enumMethodEnum.getNameCamel());
}
public void init(Integer streamOfProviderIfApplicable, EnumMethodEnum enumMethodEnum, String enumMethodUsedName, ExpressionReturnType typeInfo, List<ExprNode> parameters, ExprValidationContext validationContext) throws ExprValidationException {
final EventType eventTypeColl = typeInfo.getCollOfEventEventType();
final EventType eventTypeBean = typeInfo.getSingleEventEventType();
final Class collectionComponentType = typeInfo.getComponentType();
this.enumMethodEnum = enumMethodEnum;
this.enumMethodUsedName = enumMethodUsedName;
this.streamCountIncoming = validationContext.getStreamTypeService().getEventTypes().length;
if (eventTypeColl == null && collectionComponentType == null && eventTypeBean == null) {
throw new ExprValidationException("Invalid input for built-in enumeration method '" + enumMethodUsedName + "', expecting collection of event-type or scalar values as input, received " + typeInfo.toTypeDescriptive());
}
// compile parameter abstract for validation against available footprints
DotMethodFPProvided footprintProvided = DotMethodUtil.getProvidedFootprint(parameters);
// validate parameters
DotMethodInputTypeMatcher inputTypeMatcher = new DotMethodInputTypeMatcher() {
public boolean matches(DotMethodFP footprint) {
if (footprint.getInput() == DotMethodFPInputEnum.EVENTCOLL && eventTypeBean == null && eventTypeColl == null) {
return false;
}
if (footprint.getInput() == DotMethodFPInputEnum.SCALAR_ANY && collectionComponentType == null) {
return false;
}
return true;
}
};
DotMethodFP footprint = DotMethodUtil.validateParametersDetermineFootprint(enumMethodEnum.getFootprints(), DotMethodTypeEnum.ENUM, enumMethodUsedName, footprintProvided, inputTypeMatcher);
// validate input criteria met for this footprint
if (footprint.getInput() != DotMethodFPInputEnum.ANY) {
String message = "Invalid input for built-in enumeration method '" + enumMethodUsedName + "' and " + footprint.getParameters().length + "-parameter footprint, expecting collection of ";
String received = " as input, received " + typeInfo.toTypeDescriptive();
if (footprint.getInput() == DotMethodFPInputEnum.EVENTCOLL && typeInfo.getCollOfEventEventType() == null) {
throw new ExprValidationException(message + "events" + received);
}
if (footprint.getInput().isScalar() && typeInfo.getComponentType() == null) {
throw new ExprValidationException(message + "values (typically scalar values)" + received);
}
if (footprint.getInput() == DotMethodFPInputEnum.SCALAR_NUMERIC && !JavaClassHelper.isNumeric(collectionComponentType)) {
throw new ExprValidationException(message + "numeric values" + received);
}
}
// manage context of this lambda-expression in regards to outer lambda-expression that may call this one.
validationContext.getExprEvaluatorContext().getExpressionResultCacheService().pushStack(this);
List<ExprDotEvalParam> bodiesAndParameters = new ArrayList<ExprDotEvalParam>();
int count = 0;
EventType inputEventType = eventTypeBean == null ? eventTypeColl : eventTypeBean;
for (ExprNode node : parameters) {
ExprDotEvalParam bodyAndParameter = getBodyAndParameter(enumMethodUsedName, count++, node, inputEventType, collectionComponentType, validationContext, bodiesAndParameters, footprint);
bodiesAndParameters.add(bodyAndParameter);
}