WW-3714 Shortcut adapters

This commit is contained in:
Kusal Kithul-Godage
2024-10-17 16:51:29 +11:00
parent dfd07190bd
commit 7ce8f484e0
7 changed files with 21 additions and 0 deletions
@@ -44,6 +44,9 @@ public class ActionContext extends org.apache.struts2.ActionContext {
}
public static ActionContext adapt(org.apache.struts2.ActionContext actualContext) {
if (actualContext instanceof ActionContext) {
return (ActionContext) actualContext;
}
return actualContext != null ? new ActionContext(actualContext) : null;
}
@@ -43,6 +43,9 @@ public interface ActionEventListener extends org.apache.struts2.ActionEventListe
String handleException(Throwable t, ValueStack stack);
static ActionEventListener adapt(org.apache.struts2.ActionEventListener actualListener) {
if (actualListener instanceof ActionEventListener) {
return (ActionEventListener) actualListener;
}
return actualListener != null ? new LegacyAdapter(actualListener) : null;
}
@@ -63,6 +63,9 @@ public interface ActionInvocation extends org.apache.struts2.ActionInvocation {
void init(ActionProxy proxy);
static ActionInvocation adapt(org.apache.struts2.ActionInvocation actualInvocation) {
if (actualInvocation instanceof ActionInvocation) {
return (ActionInvocation) actualInvocation;
}
return actualInvocation != null ? new LegacyAdapter(actualInvocation) : null;
}
@@ -27,6 +27,9 @@ public interface ActionProxy extends org.apache.struts2.ActionProxy {
ActionInvocation getInvocation();
static ActionProxy adapt(org.apache.struts2.ActionProxy actualProxy) {
if (actualProxy instanceof ActionProxy) {
return (ActionProxy) actualProxy;
}
return actualProxy != null ? new LegacyAdapter(actualProxy) : null;
}
@@ -34,6 +34,9 @@ public interface Result extends org.apache.struts2.Result {
void execute(ActionInvocation invocation) throws Exception;
static Result adapt(org.apache.struts2.Result actualResult) {
if (actualResult instanceof Result) {
return (Result) actualResult;
}
return actualResult != null ? new LegacyAdapter(actualResult) : null;
}
@@ -36,6 +36,9 @@ public interface PreResultListener extends org.apache.struts2.interceptor.PreRes
void beforeResult(ActionInvocation invocation, String resultCode);
static PreResultListener adapt(org.apache.struts2.interceptor.PreResultListener actualListener) {
if (actualListener instanceof PreResultListener) {
return (PreResultListener) actualListener;
}
return actualListener != null ? new LegacyAdapter(actualListener) : null;
}
@@ -32,6 +32,9 @@ public interface ValueStack extends org.apache.struts2.util.ValueStack {
ActionContext getActionContext();
static ValueStack adapt(org.apache.struts2.util.ValueStack actualStack) {
if (actualStack instanceof ValueStack) {
return (ValueStack) actualStack;
}
return actualStack != null ? new LegacyAdapter(actualStack) : null;
}