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

io.atlassian.util.adapter.javax.el.JavaXVariableMapperAdapter Maven / Gradle / Ivy

Go to download

A collection of classes for adapting Servlet API 4.0 objects to Servlet API 5.0 and vice versa.

There is a newer version: 0.1.0
Show newest version
package io.atlassian.util.adapter.javax.el;

import io.atlassian.util.adapter.jakarta.el.JakartaValueExpressionAdapter;
import io.atlassian.util.adapter.jakarta.el.JakartaVariableMapperAdapter;

import javax.el.ValueExpression;
import javax.el.VariableMapper;

import static io.atlassian.util.adapter.util.WrapperUtil.applyIfNonNull;
import static java.util.Objects.requireNonNull;

public class JavaXVariableMapperAdapter extends VariableMapper {

    private final jakarta.el.VariableMapper delegate;

    public static VariableMapper from(jakarta.el.VariableMapper delegate) {
        if (delegate instanceof JakartaVariableMapperAdapter castDelegate) {
            return castDelegate.getDelegate();
        }
        return applyIfNonNull(delegate, JavaXVariableMapperAdapter::new);
    }

    public JavaXVariableMapperAdapter(jakarta.el.VariableMapper delegate) {
        this.delegate = requireNonNull(delegate);
    }

    public jakarta.el.VariableMapper getDelegate() {
        return delegate;
    }

    @Override
    public ValueExpression resolveVariable(String s) {
        return JavaXValueExpressionAdapter.from(delegate.resolveVariable(s));
    }

    @Override
    public ValueExpression setVariable(String s, ValueExpression valueExpression) {
        return JavaXValueExpressionAdapter.from(delegate.setVariable(s, JakartaValueExpressionAdapter.from(valueExpression)));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy