forked from Inactionware/uapi.cornerstone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inactionware#99 Add code to handle action input wire to output
- Loading branch information
Showing
14 changed files
with
383 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright (c) 2019. The UAPI Authors | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at the LICENSE file. | ||
* | ||
* You must gained the permission from the authors if you want to | ||
* use the project into a commercial product. | ||
*/ | ||
|
||
package uapi.behavior; | ||
|
||
public interface IReference { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) 2019. The UAPI Authors | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at the LICENSE file. | ||
* | ||
* You must gained the permission from the authors if you want to | ||
* use the project into a commercial product. | ||
*/ | ||
|
||
package uapi.behavior; | ||
|
||
public interface IWired { | ||
|
||
IReference toOutput(String actionLabel, String outputName); | ||
|
||
IReference toOutput(String actionLabel, int actionIndex); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
uapi.behavior/src/main/java/uapi/behavior/internal/ActionOutputHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2019. The UAPI Authors | ||
* You may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at the LICENSE file. | ||
* | ||
* You must gained the permission from the authors if you want to | ||
* use the project into a commercial product. | ||
*/ | ||
|
||
package uapi.behavior.internal; | ||
|
||
import uapi.behavior.ActionInputReference; | ||
import uapi.behavior.ActionOutputMeta; | ||
import uapi.rx.Looper; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* A class is used to holder action output data | ||
*/ | ||
public class ActionOutputHolder { | ||
|
||
private final ActionOutputMeta[] _outMetas; | ||
private final Map<String, Object> _namedDatas; | ||
private final Object[] _outDatas; | ||
|
||
ActionOutputHolder( | ||
final ActionOutputMeta[] outputMetas, | ||
final Object[] outputDatas | ||
) { | ||
this._outMetas = outputMetas; | ||
this._outDatas = outputDatas; | ||
this._namedDatas = new HashMap<>(); | ||
Looper.on(outputMetas).foreachWithIndex((idx, meta) -> { | ||
if (! meta.isAnonymous()) { | ||
this._namedDatas.put(meta.name(), outputDatas[idx]); | ||
} | ||
}); | ||
} | ||
|
||
Object getData(final ActionInputReference inRef) { | ||
Object data = null; | ||
if (inRef.name() != null) { | ||
data = this._namedDatas.get(inRef.name()); | ||
} | ||
if (data != null) { | ||
return data; | ||
} | ||
return data; | ||
} | ||
} |
Oops, something went wrong.