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

io.atlassian.util.adapter.jakarta.servlet.jsp.el.JakartaVariableResolverAdapter 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.jakarta.servlet.jsp.el;

import io.atlassian.util.adapter.javax.servlet.jsp.el.JavaXVariableResolverAdapter;
import jakarta.servlet.jsp.el.ELException;
import jakarta.servlet.jsp.el.VariableResolver;

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

public class JakartaVariableResolverAdapter implements VariableResolver {

    private final javax.servlet.jsp.el.VariableResolver delegate;

    public static VariableResolver from(javax.servlet.jsp.el.VariableResolver delegate) {
        if (delegate instanceof JavaXVariableResolverAdapter castDelegate) {
            return castDelegate.getDelegate();
        }
        return applyIfNonNull(delegate, JakartaVariableResolverAdapter::new);
    }

    JakartaVariableResolverAdapter(javax.servlet.jsp.el.VariableResolver delegate) {
        this.delegate = requireNonNull(delegate);
    }

    public javax.servlet.jsp.el.VariableResolver getDelegate() {
        return delegate;
    }

    @Override
    public Object resolveVariable(String s) throws ELException {
        try {
            return delegate.resolveVariable(s);
        } catch (javax.servlet.jsp.el.ELException e) {
            throw new ELException(e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy