CreateObject
See javadoc - uk.gov.gchq.koryphe.impl.function.CreateObject
Available since Koryphe version 1.7.0
Creates a new object of a given type
Examples
String example
Java
JSON
Full JSON
Python
final CreateObject createObject = new CreateObject(String.class);
{
"class" : "CreateObject",
"objectClass" : "String"
}
{
"class" : "uk.gov.gchq.koryphe.impl.function.CreateObject",
"objectClass" : "java.lang.String"
}
g.CreateObject(
object_class="java.lang.String"
)
Input type:
java.lang.Object
Example inputs:
Input Type | Input | Result Type | Result |
---|---|---|---|
java.lang.String | a normal string | java.lang.String | a normal string |
byte[] | some bytes | java.lang.String | some bytes |
null | java.lang.String | ||
java.lang.Integer | 123 | RuntimeException: Unable to create a new instance of java.lang.String. No constructors were found that accept a java.lang.Integer | |
[C | [C@37257c12 | java.lang.String | a char array |
List example
Java
JSON
Full JSON
Python
final CreateObject createObject = new CreateObject(ArrayList.class);
{
"class" : "CreateObject",
"objectClass" : "ArrayList"
}
{
"class" : "uk.gov.gchq.koryphe.impl.function.CreateObject",
"objectClass" : "java.util.ArrayList"
}
g.CreateObject(
object_class="java.util.ArrayList"
)
Input type:
java.lang.Object
Example inputs:
Input Type | Input | Result Type | Result |
---|---|---|---|
java.util.ArrayList | [list, example] | java.util.ArrayList | [list, example] |
java.util.HashSet | [set, example] | java.util.ArrayList | [set, example] |
java.util.HashMap | {} | RuntimeException: Unable to create a new instance of java.util.ArrayList. No constructors were found that accept a java.util.HashMap | |
null | java.util.ArrayList | [] |