- java.lang.Object
-
- io.virtdata.core.VirtData
-
public class VirtData extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description VirtData()
-
Method Summary
Modifier and Type Method Description static <T> TgetFunction(java.lang.String flowSpec, java.lang.Class<? extends T> functionType)static <T> DataMapper<T>getMapper(java.lang.String flowSpec)Instantiate a data mapping function, or throw an exception.static <T> DataMapper<T>getMapper(java.lang.String flowSpec, java.lang.Class<? extends T> clazz)Instantiate a data mapping function of the specified type, or throw an error.static ResolverDiagnosticsgetMapperDiagnostics(java.lang.String flowSpec)static <T> java.util.Optional<T>getOptionalFunction(java.lang.String flowSpec, java.lang.Class<? extends T> functionType)static <T> java.util.Optional<DataMapper<T>>getOptionalMapper(java.lang.String flowSpec)Instantiate an optional data mapping function if possible.static <T> java.util.Optional<DataMapper<T>>getOptionalMapper(java.lang.String flowSpec, java.lang.Class<? extends T> clazz)Instantiate an optional data mapping function if possible, with type awareness.static BindingsTemplategetTemplate(java.lang.String... namesAndSpecs)Create a bindings template from the pair-wise names and specifiers.static BindingsTemplategetTemplate(java.util.List<BindPoint> bindPoints)Create a bindings template from a provided list ofBindPoints, ensuring that the syntax of the bindings specs is parsable first.
-
-
-
Method Detail
-
getTemplate
public static BindingsTemplate getTemplate(java.lang.String... namesAndSpecs)
Create a bindings template from the pair-wise names and specifiers. Each even-numbered (starting with zero) argument is a binding name, and each odd-numbered (starting with one) argument is a binding spec.- Parameters:
namesAndSpecs- names and specs in "name", "spec", ... form- Returns:
- A bindings template that can be used to resolve a bindings instance
-
getTemplate
public static BindingsTemplate getTemplate(java.util.List<BindPoint> bindPoints)
Create a bindings template from a provided list ofBindPoints, ensuring that the syntax of the bindings specs is parsable first.- Parameters:
bindPoints- A list ofBindPoints- Returns:
- A BindingsTemplate
-
getOptionalMapper
public static <T> java.util.Optional<DataMapper<T>> getOptionalMapper(java.lang.String flowSpec)
Instantiate an optional data mapping function if possible.- Type Parameters:
T- The parameterized return type of the function- Parameters:
flowSpec- The VirtData specifier for the mapping function- Returns:
- An optional function which will be empty if the function could not be resolved.
-
getMapperDiagnostics
public static ResolverDiagnostics getMapperDiagnostics(java.lang.String flowSpec)
-
getOptionalMapper
public static <T> java.util.Optional<DataMapper<T>> getOptionalMapper(java.lang.String flowSpec, java.lang.Class<? extends T> clazz)
Instantiate an optional data mapping function if possible, with type awareness. This version ofgetOptionalMapper(String)will use the additional type information in the clazz parameter to automatically parameterize the flow specifier. If the flow specifier does contain an output type qualifier already, then a check is made to ensure that the output type qualifier is assignable to the specified class in the clazz parameter. This ensures that type parameter awareness at compile time is honored and verified when this call is made.- Type Parameters:
T- The parameterized return type of the function.- Parameters:
flowSpec- The VirtData specifier for the mapping functionclazz- The explicit class which must be of type T or assignable to type T- Returns:
- An optional function which will be empty if the function could not be resolved.
-
getFunction
public static <T> T getFunction(java.lang.String flowSpec, java.lang.Class<? extends T> functionType)
-
getOptionalFunction
public static <T> java.util.Optional<T> getOptionalFunction(java.lang.String flowSpec, java.lang.Class<? extends T> functionType)
-
getMapper
public static <T> DataMapper<T> getMapper(java.lang.String flowSpec)
Instantiate a data mapping function, or throw an exception.- Type Parameters:
T- The parameterized return type of the function- Parameters:
flowSpec- The VirtData specifier for the mapping function- Returns:
- A data mapping function
- Throws:
java.lang.RuntimeException- if the function could not be resolved
-
getMapper
public static <T> DataMapper<T> getMapper(java.lang.String flowSpec, java.lang.Class<? extends T> clazz)
Instantiate a data mapping function of the specified type, or throw an error.- Type Parameters:
T- The parameterized class of the data mapping return type- Parameters:
flowSpec- The VirtData flow specifier for the function to be returnedclazz- The class of the data mapping function return type- Returns:
- A new data mapping function.
- Throws:
java.lang.RuntimeException- if the function could not be resolved
-
-