/** * Tells you if the expression is true, which can be true or Boolean.TRUE. * @param expression * expression * @return * as described */ public static boolean isTrue(Expression expression) { if (expression == null) { return false; } if (expression instanceof PropertyExpression && classNodeImplementsType(((PropertyExpression) expression).getObjectExpression().getType(), Boolean.class)) { if (((PropertyExpression) expression).getProperty() instanceof ConstantExpression && "TRUE".equals(((ConstantExpression) ((PropertyExpression) expression).getProperty()).getValue())) { return true; } } return ((expression instanceof ConstantExpression) && ((ConstantExpression) expression).isTrueExpression()) || "Boolean.TRUE".equals(expression.getText()); }
public static void addListenerToProperty(SourceUnit source, AnnotationNode annotation, ClassNode declaringClass, FieldNode field) { Expression value = annotation.getMember(VALUE); Expression weak = annotation.getMember("weak"); boolean useWeakListener = false; if (weak != null && weak instanceof ConstantExpression && ((ConstantExpression) weak).isTrueExpression()) { useWeakListener = true; } if ((value instanceof ListExpression)) { for (Expression expr : ((ListExpression) value).getExpressions()) { processExpression(declaringClass, field.getName(), expr, useWeakListener); } annotation.setMember(VALUE, new ConstantExpression(EMPTY_STRING)); } else { processExpression(declaringClass, field.getName(), value, useWeakListener); annotation.setMember(VALUE, new ConstantExpression(EMPTY_STRING)); } }
public static void addListenerToProperty(SourceUnit source, AnnotationNode annotation, ClassNode declaringClass, FieldNode field) { Expression value = annotation.getMember(VALUE); Expression weak = annotation.getMember("weak"); boolean useWeakListener = false; if (weak != null && weak instanceof ConstantExpression && ((ConstantExpression) weak).isTrueExpression()) { useWeakListener = true; } if ((value instanceof ListExpression)) { for (Expression expr : ((ListExpression) value).getExpressions()) { processExpression(declaringClass, field.getName(), expr, useWeakListener); } annotation.setMember(VALUE, new ConstantExpression(EMPTY_STRING)); } else { processExpression(declaringClass, field.getName(), value, useWeakListener); annotation.setMember(VALUE, new ConstantExpression(EMPTY_STRING)); } }
public static void addListenerToProperty(SourceUnit source, AnnotationNode annotation, ClassNode declaringClass, FieldNode field) { Expression value = annotation.getMember(VALUE); Expression weak = annotation.getMember("weak"); boolean useWeakListener = false; if (weak != null && weak instanceof ConstantExpression && ((ConstantExpression) weak).isTrueExpression()) { useWeakListener = true; } if ((value instanceof ListExpression)) { for (Expression expr : ((ListExpression) value).getExpressions()) { processExpression(declaringClass, field.getName(), expr, useWeakListener); } annotation.setMember(VALUE, new ConstantExpression(EMPTY_STRING)); } else { processExpression(declaringClass, field.getName(), value, useWeakListener); annotation.setMember(VALUE, new ConstantExpression(EMPTY_STRING)); } }
public static void addListenerToProperty(SourceUnit source, AnnotationNode annotation, ClassNode declaringClass, FieldNode field) { Expression value = annotation.getMember(VALUE); Expression weak = annotation.getMember("weak"); boolean useWeakListener = false; if (weak != null && weak instanceof ConstantExpression && ((ConstantExpression) weak).isTrueExpression()) { useWeakListener = true; } if ((value instanceof ListExpression)) { for (Expression expr : ((ListExpression) value).getExpressions()) { processExpression(declaringClass, field.getName(), expr, useWeakListener); } annotation.setMember(VALUE, new ConstantExpression(EMPTY_STRING)); } else { processExpression(declaringClass, field.getName(), value, useWeakListener); annotation.setMember(VALUE, new ConstantExpression(EMPTY_STRING)); } }