public static void forceCastForName(String nameRef, Type type, Expression expression) {
        List<NameExpr> allNameExprForName = expression.findAll(NameExpr.class, n -> n.getNameAsString().equals(nameRef));
        for (NameExpr n : allNameExprForName) {
            n.getParentNode().get().replace(n, new EnclosedExpr(new CastExpr(type, n)));
        }
    }
public static void forceCastForName ( String nameRef , Type type , Expression expression ) { List < NameExpr > allNameExprForName = expression . findAll ( NameExpr . class , n -> n . getNameAsString ( ) . equals ( nameRef ) ) ; for ( NameExpr n : allNameExprForName ) { n . getParentNode ( ) . get ( ) . replace ( n , new EnclosedExpr ( new CastExpr ( type , n ) ) ) ; } }
Mutates expression
such that, if it contains a <pre>nameRef</pre>, it is replaced and forcibly casted with <pre>(type) nameRef</pre>.

@param expression a mutated expression