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
byte[]some bytesjava.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@37257c12java.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 ""