Refactor from(:PdxInstance) factory method to handle PdxInstanceWrapper arguments.

The from(:PdxInstance) method should not wrap a PdxInstance more than once.

Format source code.
This commit is contained in:
John Blum
2020-06-10 02:59:34 -07:00
parent 450cc58d82
commit 0a3c2bb7ab
2 changed files with 18 additions and 2 deletions

View File

@@ -77,7 +77,10 @@ public class PdxInstanceWrapper implements PdxInstance, Sendable {
* @see #from(PdxInstance)
*/
public static Object from(Object target) {
return target instanceof PdxInstance ? from((PdxInstance) target) : target;
return target instanceof PdxInstance
? from((PdxInstance) target)
: target;
}
/**
@@ -91,7 +94,10 @@ public class PdxInstanceWrapper implements PdxInstance, Sendable {
* @see #PdxInstanceWrapper(PdxInstance)
*/
public static PdxInstanceWrapper from(PdxInstance pdxInstance) {
return new PdxInstanceWrapper(pdxInstance);
return pdxInstance instanceof PdxInstanceWrapper
? (PdxInstanceWrapper) pdxInstance
: new PdxInstanceWrapper(pdxInstance);
}
/**