Utility method to create a JSF Value expression from p_expression with
exprectedType class as return

@param p_expression
@param expectedType
@return
321023
public static ValueExpression createValueExpression(String p_expression, Class<?> expectedType) {
		FacesContext context = FacesContext.getCurrentInstance();
		ExpressionFactory expressionFactory = context.getApplication().getExpressionFactory();
		ELContext elContext = context.getELContext();
		if (null == expectedType) {
			LOGGER.severe("The expected type of " + p_expression + " is null. Defaulting to String.");
			expectedType = String.class;
		}
		ValueExpression vex = expressionFactory.createValueExpression(elContext, p_expression, expectedType);
		return vex;
	}
745482
public static function checkResponse($response, $expectedType)
    {
        $rspCode = $response->Header->GatewayRspCode;
        $rspText = $response->Header->GatewayRspMsg;
        $transactionId = (isset($response->Header->GatewayTxnId) ? $response->Header->GatewayTxnId : null);
        $e = HpsGatewayResponseValidation::getException($rspCode, $rspText, $response);

        if ($e != null) {
            if ($e instanceof HpsGatewayException) {
                $e->transactionId = $transactionId;
            }
            throw $e;
        }
        if (!isset($response->Transaction) || !isset($response->Transaction->$expectedType)) {
            throw new HpsGatewayException(
                HpsExceptionCodes::UNEXPECTED_GATEWAY_ERROR,
                'Unexpected response from HPS gateway',
                null,
                null,
                null,
                $transactionId
            );
        }
    }
1365770
def p_expression_inlist(self, p):
        '''  
        '''
        _LOGGER.debug("expresion -> expresion IN lexp")

        if self._autodefine_vars:
            self._init_vars(TypedList([]), p[3])

        if p[3].type != TypedClass.LIST: raise TypeError("expected list for IN operator")
        
        retval = False
        for v in p[3].value:
            if p[1] == v:
                retval = True
                break
        
        p[0] = TypedClass(retval, TypedClass.BOOLEAN)
1100454
protected LightweightTypeReference getExpectedType(XtendExecutable executable, JvmTypeReference declaredReturnType) {
		if (declaredReturnType == null) {
			// Try to get any inferred return type.
			if (executable instanceof XtendFunction) {
				final XtendFunction function = (XtendFunction) executable;
				final JvmOperation operation = this.sarlAssociations.getDirectlyInferredOperation(function);
				if (operation != null) {
					return Utils.toLightweightTypeReference(operation.getReturnType(), this.services);
				}
			}
			if (!getEarlyExitComputer().isEarlyExit(executable.getExpression())) {
				return getExpectedType(executable.getExpression());
			}
			return null;
		}
		if (!"void".equals(declaredReturnType.getIdentifier())) { //$NON-NLS-1$
			return Utils.toLightweightTypeReference(declaredReturnType, this.services);
		}
		return null;
	}
407375
private void evaluateExpressions() throws JspException {
        /* 
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

        value = (String) ExpressionUtil.evalNotNull(
                "url", "value", value_, String.class, this, pageContext);
        context = (String) ExpressionUtil.evalNotNull(
                "url", "context", context_, String.class, this, pageContext);
    }
510212
public static boolean isExpectedType(final Class<?> expectedClass, final Object obj) {
        final Class<?> actualClass;
        if (obj == null) {
            actualClass = null;
        } else {
            actualClass = obj.getClass();
        }
        return Objects.equals(expectedClass, actualClass);
    }
751951
@SuppressWarnings("unchecked")
    private void writeValue(Type expected, Object value, TreePruner pruner, DataWriter writer, boolean skipIfFail) throws IOException {
        if(value==null) {
            writer.valueNull();
            return;
        }

        if(value instanceof CustomExportedBean) {
            writeValue(expected,((CustomExportedBean)value).toExportedObject(),pruner,writer);
            return;
        }

        Class c = value.getClass();

        Model model = owner.getOrNull(c, parent.type, name);
        if (model == null) {
            if(STRING_TYPES.contains(c)) {
                writer.value(value.toString());
                return;
            }
            if(PRIMITIVE_TYPES.contains(c)) {
                writer.valuePrimitive(value);
                return;
            }
            Class act = c.getComponentType();
            if (act !=null) { // array
                Range r = pruner.getRange();
                writer.startArray();
                if (value instanceof Object[]) {
                    // typical case
                    for (Object item : r.apply((Object[]) value)) {
                        writeBuffered(act, item, pruner, writer);
                    }
                } else {
                    // more generic case
                    int len = Math.min(r.max, Array.getLength(value));
                    for (int i=r.min; i<len; i++) {
                        writeBuffered(act, Array.get(value, i), pruner, writer);
                    }
                }
                writer.endArray();
                return;
            }
            if(value instanceof Iterable) {
                writer.startArray();
                Type expectedItemType = Types.getTypeArgument(expected, 0, null);
                for (Object item : pruner.getRange().apply((Iterable) value)) {
                    writeBuffered(expectedItemType, item, pruner, writer);
                }
                writer.endArray();
                return;
            }
            if(value instanceof Map) {
                if (verboseMap!=null) {// verbose form
                    writer.startArray();
                    for (Map.Entry e : ((Map<?,?>) value).entrySet()) {
                        BufferedDataWriter buffer = new BufferedDataWriter(writer.getExportConfig());
                        try {
                            writeStartObjectNullType(buffer);
                            buffer.name(verboseMap[0]);
                            writeValue(null, e.getKey(), pruner, buffer);
                            buffer.name(verboseMap[1]);
                            writeValue(null, e.getValue(), pruner, buffer);
                            buffer.endObject();
                            buffer.finished();
                        } catch (IOException x) {
                            if (x.getCause() instanceof InvocationTargetException) {
                                LOGGER.log(Level.WARNING, "skipping export of " + e, x);
                            }
                        }
                        buffer.commit(writer);
                    }
                    writer.endArray();
                } else {// compact form
                    writeStartObjectNullType(writer);
                    for (Map.Entry e : ((Map<?,?>) value).entrySet()) {
                        BufferedDataWriter buffer = new BufferedDataWriter(writer.getExportConfig());
                        try {
                            buffer.name(e.getKey().toString());
                            writeValue(null, e.getValue(), pruner, buffer);
                            buffer.finished();
                        } catch (IOException x) {
                            if (x.getCause() instanceof InvocationTargetException) {
                                LOGGER.log(Level.WARNING, "skipping export of " + e, x);
                            }
                        }
                        buffer.commit(writer);
                    }
                    writer.endObject();
                }
                return;
            }
            if(value instanceof Date) {
                writer.valuePrimitive(((Date) value).getTime());
                return;
            }
            if(value instanceof Calendar) {
                writer.valuePrimitive(((Calendar) value).getTimeInMillis());
                return;
            }
            if(value instanceof Enum) {
                writer.value(value.toString());
                return;
            }

            if (skipIfFail) {
                writer.startObject();
                writer.endObject();
                return;
            }

            throw new NotExportableException(c);
        } else {
            writer.type(expected, value.getClass());
            writer.startObject();
            model.writeNestedObjectTo(value, pruner, writer);
            writer.endObject();
        }
    }
75972
private void evaluateExpressions() throws JspException {
        /*
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

        if (begin_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                    "begin", begin_, Integer.class, this, pageContext);
            if (r == null) {
                throw new NullAttributeException("forTokens", "begin");
            }
            begin = ((Integer) r).intValue();
            validateBegin();
        }

        if (end_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                    "end", end_, Integer.class, this, pageContext);
            if (r == null) {
                throw new NullAttributeException("forTokens", "end");
            }
            end = ((Integer) r).intValue();
            validateEnd();
        }

        if (step_ != null) {
            Object r = ExpressionEvaluatorManager.evaluate(
                    "step", step_, Integer.class, this, pageContext);
            if (r == null) {
                throw new NullAttributeException("forTokens", "step");
            }
            step = ((Integer) r).intValue();
            validateStep();
        }

        if (items_ != null) {
            items = (String) ExpressionEvaluatorManager.evaluate(
                    "items", items_, String.class, this, pageContext);
            // use the empty string to indicate "no iteration"
            if (items == null) {
                items = "";
            }
        }

        if (delims_ != null) {
            delims = (String) ExpressionEvaluatorManager.evaluate(
                    "delims", delims_, String.class, this, pageContext);
            // use the empty string to cause monolithic tokenization
            if (delims == null) {
                delims = "";
            }
        }
    }
1282678
static <T> T getInstance(Annotation annotation, Class<T> expectedType) {
        try {
            @SuppressWarnings("unchecked")
            final Class<? extends T> clazz = (Class<? extends T>) invokeValueMethod(annotation);
            return expectedType.cast(instanceCache.computeIfAbsent(clazz, type -> {
                try {
                    return getInstance0(clazz);
                } catch (Exception e) {
                    throw new IllegalStateException(
                            "A class specified in @" + annotation.getClass().getSimpleName() +
                            " annotation must have an accessible default constructor: " + clazz.getName(), e);
                }
            }));
        } catch (ClassCastException e) {
            throw new IllegalArgumentException(
                    "A class specified in @" + annotation.getClass().getSimpleName() +
                    " annotation cannot be cast to " + expectedType, e);
        }
    }
964190
protected LightweightTypeReference getExpectedType(XExpression expr) {
		final IResolvedTypes resolvedTypes = getTypeResolver().resolveTypes(expr);
		final LightweightTypeReference actualType = resolvedTypes.getActualType(expr);
		return actualType;
	}
764116
static final Parser<Expression> castOrExpression(Parser<Expression> expr) {
    Parser<Expression> explicitCast =
        Parsers.sequence(paren(TypeLiteralParser.TYPE_LITERAL), expr, CastExpression::new);
    return explicitCast.or(paren(expr));
  }
145942
private void evaluateExpressions() throws JspException {
        /* 
         * Note: we don't check for type mismatches here; we assume
         * the expression evaluator will return the expected type
         * (by virtue of knowledge we give it about what that type is).
         * A ClassCastException here is truly unexpected, so we let it
         * propagate up.
         */

        if (value_ != null) {
            value = ExpressionEvaluatorManager.evaluate(
                    "value", value_, Object.class, this, pageContext);
        }
    }
859312
public static boolean matchValueByName(String expectedType, Object actualValue) {
		if (expectedType == null)
			return true;
		if (actualValue == null)
			throw new NullPointerException("Actual value cannot be null");

		return matchTypeByName(expectedType, actualValue.getClass());
	}
383065
Object convertToExpectedType(Object pValue,
                                 Class pExpectedType,
                                 Logger pLogger)
            throws ELException {
        return Coercions.coerce(pValue,
                pExpectedType,
                pLogger);
    }
2500
protected LightweightTypeReference getMapExpectation(LightweightTypeReference expectation) {
		if (expectation != null && expectation.isResolved()) {
			LightweightTypeReference result = expectation.getSuperType(Map.class);
			if (result != null && result.getTypeArguments().size() == 2) {
				return result;
			}
		}
		return null;
	}
285076
public static <T> T resolveValue(ValueExpression expression, Class<T> type, ELContext elContext) {
		if(expression == null) {
			return null;
		} else {
			return type.cast(expression.getValue(elContext));
		}
	}
412695
Type checkSpeculative(JCExpression expr, ResultInfo resultInfo) {
        return checkSpeculative(expr, expr.type, resultInfo);
    }