Skip to content

Commit 02e27d0

Browse files
committed
feat: added ScriptFunctionArgument#getType
1 parent a0e9fd1 commit 02e27d0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

api/src/main/java/com/instancify/scriptify/api/script/function/argument/ScriptFunctionArgument.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ public interface ScriptFunctionArgument {
1212
*/
1313
Object getValue();
1414

15+
/**
16+
* Retrieves type the of value of this argument.
17+
*
18+
* @return Type the value of the argument
19+
*/
20+
default Class<?> getType() {
21+
return this.getValue().getClass();
22+
}
23+
1524
/**
1625
* Checks if the value of this argument is an instance of the specified class.
1726
*

core/src/main/java/com/instancify/scriptify/core/script/function/impl/ScriptFunctionShuffleArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public Object invoke(Script<?> script, ScriptFunctionArgument[] args) throws Scr
2929
}
3030

3131
if (!(args[0].getValue() instanceof List<?> array)) {
32-
throw new ScriptFunctionArgTypeException(List.class, args[0].getValue().getClass());
32+
throw new ScriptFunctionArgTypeException(List.class, args[0].getType());
3333
}
3434

3535
List<?> list = new ArrayList<Object>(array);

0 commit comments

Comments
 (0)