Skip to content

Commit a74f399

Browse files
committed
WW-3714 Shortcut adapters
1 parent 9d76bd4 commit a74f399

File tree

7 files changed

+21
-0
lines changed

7 files changed

+21
-0
lines changed

core/src/main/java/com/opensymphony/xwork2/ActionContext.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ private ActionContext(org.apache.struts2.ActionContext actualContext) {
4444
}
4545

4646
public static ActionContext adapt(org.apache.struts2.ActionContext actualContext) {
47+
if (actualContext instanceof ActionContext) {
48+
return (ActionContext) actualContext;
49+
}
4750
return actualContext != null ? new ActionContext(actualContext) : null;
4851
}
4952

core/src/main/java/com/opensymphony/xwork2/ActionEventListener.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ default String handleException(Throwable t, org.apache.struts2.util.ValueStack s
4343
String handleException(Throwable t, ValueStack stack);
4444

4545
static ActionEventListener adapt(org.apache.struts2.ActionEventListener actualListener) {
46+
if (actualListener instanceof ActionEventListener) {
47+
return (ActionEventListener) actualListener;
48+
}
4649
return actualListener != null ? new LegacyAdapter(actualListener) : null;
4750
}
4851

core/src/main/java/com/opensymphony/xwork2/ActionInvocation.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ default void init(org.apache.struts2.ActionProxy proxy) {
6363
void init(ActionProxy proxy);
6464

6565
static ActionInvocation adapt(org.apache.struts2.ActionInvocation actualInvocation) {
66+
if (actualInvocation instanceof ActionInvocation) {
67+
return (ActionInvocation) actualInvocation;
68+
}
6669
return actualInvocation != null ? new LegacyAdapter(actualInvocation) : null;
6770
}
6871

core/src/main/java/com/opensymphony/xwork2/ActionProxy.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public interface ActionProxy extends org.apache.struts2.ActionProxy {
2727
ActionInvocation getInvocation();
2828

2929
static ActionProxy adapt(org.apache.struts2.ActionProxy actualProxy) {
30+
if (actualProxy instanceof ActionProxy) {
31+
return (ActionProxy) actualProxy;
32+
}
3033
return actualProxy != null ? new LegacyAdapter(actualProxy) : null;
3134
}
3235

core/src/main/java/com/opensymphony/xwork2/Result.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ default void execute(org.apache.struts2.ActionInvocation invocation) throws Exce
3434
void execute(ActionInvocation invocation) throws Exception;
3535

3636
static Result adapt(org.apache.struts2.Result actualResult) {
37+
if (actualResult instanceof Result) {
38+
return (Result) actualResult;
39+
}
3740
return actualResult != null ? new LegacyAdapter(actualResult) : null;
3841
}
3942

core/src/main/java/com/opensymphony/xwork2/interceptor/PreResultListener.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ default void beforeResult(org.apache.struts2.ActionInvocation invocation, String
3636
void beforeResult(ActionInvocation invocation, String resultCode);
3737

3838
static PreResultListener adapt(org.apache.struts2.interceptor.PreResultListener actualListener) {
39+
if (actualListener instanceof PreResultListener) {
40+
return (PreResultListener) actualListener;
41+
}
3942
return actualListener != null ? new LegacyAdapter(actualListener) : null;
4043
}
4144

core/src/main/java/com/opensymphony/xwork2/util/ValueStack.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public interface ValueStack extends org.apache.struts2.util.ValueStack {
3232
ActionContext getActionContext();
3333

3434
static ValueStack adapt(org.apache.struts2.util.ValueStack actualStack) {
35+
if (actualStack instanceof ValueStack) {
36+
return (ValueStack) actualStack;
37+
}
3538
return actualStack != null ? new LegacyAdapter(actualStack) : null;
3639
}
3740

0 commit comments

Comments
 (0)