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 TypeInputResult TypeResult
java.lang.Stringa normal stringjava.lang.Stringa normal string
[B[B@56e6fa0ejava.lang.Stringsome bytes
nulljava.lang.String
java.lang.Integer123RuntimeException: Unable to create a new instance of java.lang.String. No constructors were found that accept a java.lang.Integer
[C[C@6269d45cjava.lang.Stringa 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 TypeInputResult TypeResult
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
nulljava.util.ArrayList[]

results matching ""

    No results matching ""