io.nosqlbench.virtdata.core.bindings.DataMapperLibrary Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of driver-cql-shaded Show documentation
Show all versions of driver-cql-shaded Show documentation
A Shaded CQL ActivityType driver for http://nosqlbench.io/
package io.nosqlbench.virtdata.core.bindings;
import java.util.List;
import java.util.Optional;
/**
*
* A DataMapperLibrary is an independently loadable library of data mapping functions.
*
*/
public interface DataMapperLibrary {
/**
* Return the name for this data mapper implementation, as it can be used in spec strings, etc.
*
* @return Simple lower-case canonical library name
*/
String getLibraryName();
/**
* Find the implementation for and construct an instance of a data mapper function, as described.
*
* @param spec A specifier that describes the type and or parameterization of a data mapping function instance.
* @param The result type produced by the data mapping function.
* @return An optional data mapping function instance
*/
default Optional> getDataMapper(String spec) {
if (canParseSpec(spec)) {
Optional resolvedFunction = resolveFunction(spec);
return resolvedFunction
.map(ResolvedFunction::getFunctionObject)
.map(DataMapperFunctionMapper::map);
}
return Optional.empty();
}
default Optional> getOptionalDataMapper(String spec, Class extends T> clazz) {
return Optional.ofNullable(getDataMapper(spec, clazz));
}
@SuppressWarnings("unchecked")
default DataMapper getDataMapper(String spec, Class extends T> clazz) {
if (!canParseSpec(spec)) {
return null;
}
Optional resolvedFunction = resolveFunction(spec);
if (!resolvedFunction.isPresent()) {
return null;
}
ResolvedFunction rf = resolvedFunction.get();
DataMapper
© 2015 - 2025 Weber Informatics LLC | Privacy Policy