All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.aspectj.configuration.model.Expression Maven / Gradle / Ivy

Go to download

Scripting extension for AspectJ agent. Allow java bytecode instrumentation at jvm startup by using MVEL expression and execute code from maven artifacts

The newest version!
package org.aspectj.configuration.model;

import org.aspectj.util.Utils;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 *
 */
@XmlAccessorType(XmlAccessType.FIELD)
public class Expression {
    private String expression;
    private Map params;


    Expression() {
    }

    public Expression(String expression) {
        this.expression = expression;
    }

    public Expression(String expression, Map params) {
        this.expression = expression;
        this.params = params;
    }
    
    public boolean isNotEmpty() {
        return isNotEmptyExpression(this);
    }
    
    public static boolean isNotEmptyExpression(Expression expression) {
        return expression !=null && expression.getExpression()!=null && !expression.getExpression().trim().isEmpty();
    }

    public String getExpression() {
        return expression;
    }

    public Map getResultParams() {
        if(params == null || params.size() == 0) return null;
        Map resultParams = new HashMap(params.size());
        Set> entries = params.entrySet();
        for(Map.Entry entry: entries){
            String sourceValue = entry.getValue();
            String key = entry.getKey();
            try {
                Object value = Utils.checkMvelExpression(sourceValue);
                resultParams.put(key, value);
            } catch (Exception e) {
                throw new IllegalArgumentException("Parameter name '"+key+"'", e);
            }
        }
        return resultParams;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy