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

io.atlassian.util.adapter.javax.el.JavaXValueExpressionAdapter 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 javax.el.ELContext;
import javax.el.ValueExpression;
import javax.el.ValueReference;

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

public class JavaXValueExpressionAdapter extends ValueExpression {

    private final jakarta.el.ValueExpression delegate;

    public static ValueExpression from(jakarta.el.ValueExpression delegate) {
        if (delegate instanceof JakartaValueExpressionAdapter castDelegate) {
            return castDelegate.getDelegate();
        }
        return applyIfNonNull(delegate, JavaXValueExpressionAdapter::new);
    }

    JavaXValueExpressionAdapter(jakarta.el.ValueExpression delegate) {
        this.delegate = requireNonNull(delegate);
    }

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

    @Override
    public ValueReference getValueReference(ELContext context) {
        return JavaXValueReferenceAdapter.from(delegate.getValueReference(asJakartaJsp(context)));
    }

    @Override
    public Object getValue(ELContext elContext) {
        return delegate.getValue(asJakartaJsp(elContext));
    }

    @Override
    public void setValue(ELContext elContext, Object o) {
        delegate.setValue(asJakartaJsp(elContext), o);
    }

    @Override
    public boolean isReadOnly(ELContext elContext) {
        return delegate.isReadOnly(asJakartaJsp(elContext));
    }

    @Override
    public Class getType(ELContext elContext) {
        return delegate.getType(asJakartaJsp(elContext));
    }

    @Override
    public Class getExpectedType() {
        return delegate.getExpectedType();
    }

    @Override
    public String getExpressionString() {
        return delegate.getExpressionString();
    }

    @Override
    public boolean equals(Object o) {
        return delegate.equals(o);
    }

    @Override
    public int hashCode() {
        return delegate.hashCode();
    }

    @Override
    public boolean isLiteralText() {
        return delegate.isLiteralText();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy