Class ELKIBuilder<T>
- java.lang.Object
-
- elki.utilities.ELKIBuilder<T>
-
- Type Parameters:
T
- Class to build.
public final class ELKIBuilder<T> extends java.lang.Object
Builder utility class.This class delegates to
ListParameterization
andClassGenericsUtil
, but may be easier to use in many cases.You will often need to specify the type T, because of nested generics. This is because of the way generics are implemented in Java, and we cannot easily resolve this; you have to give the type explicitly.
Example:
RStarTreeFactory<DoubleVector> indexfactory = new ELKIBuilder<RStarTreeFactory<DoubleVector>>(RStarTreeFactory.class) .with(AbstractPageFileFactory.Par.PAGE_SIZE_ID, 512) .with(RStarTreeFactory.Par.BULK_SPLIT_ID, SortTileRecursiveBulkSplit.class) .build();
withnew ELKIBuilder<RStarTreeFactory<DoubleVector>>
this code is fine, whereasnew ELKIBuilder<>
will cause an unchecked cast warning, because you are, in fact, casting aRStarTreeFactory
(without generics) into aRStarTreeFactory<DoubleVector>
here.- Since:
- 0.7.5
- Author:
- Erich Schubert
-
-
Constructor Summary
Constructors Constructor Description ELKIBuilder(java.lang.Class<? super T> clazz)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <C extends T>
Cbuild()
Instantiate, consuming the parameter list.ELKIBuilder<T>
with(OptionID opt)
Add a flag to the builder.ELKIBuilder<T>
with(OptionID opt, java.lang.Object value)
Add an option to the builder.ELKIBuilder<T>
with(java.lang.String opt)
Add a flag to the builder.ELKIBuilder<T>
with(java.lang.String opt, java.lang.Object value)
Add an option to the builder.
-
-
-
Field Detail
-
LOG
private static final Logging LOG
Class logger.
-
clazz
private java.lang.Class<? super T> clazz
Class to build.
-
p
private ListParameterization p
Parameter list.
-
-
Constructor Detail
-
ELKIBuilder
public ELKIBuilder(java.lang.Class<? super T> clazz)
Constructor.You will often need to specify the type T, because of nested generics. This is because of the way generics are implemented in Java, and we cannot easily resolve this; you have to give the type explicitly.
Example:
RStarTreeFactory<DoubleVector> indexfactory = new ELKIBuilder<RStarTreeFactory<DoubleVector>>(RStarTreeFactory.class) .with(AbstractPageFileFactory.Par.PAGE_SIZE_ID, 512) .with(RStarTreeFactory.Par.BULK_SPLIT_ID, SortTileRecursiveBulkSplit.class) .build();
withnew ELKIBuilder<RStarTreeFactory<DoubleVector>>
this code is fine, whereasnew ELKIBuilder<>
will cause an unchecked cast warning, because you are, in fact, casting aRStarTreeFactory
(without generics) into aRStarTreeFactory<DoubleVector>
here.- Parameters:
clazz
- Class
-
-
Method Detail
-
with
public ELKIBuilder<T> with(OptionID opt, java.lang.Object value)
Add an option to the builder.- Parameters:
opt
- Option ID (usually found in the Parameterizer class)value
- Value- Returns:
- The same builder
-
with
public ELKIBuilder<T> with(OptionID opt)
Add a flag to the builder.- Parameters:
opt
- Option ID (usually found in the Parameterizer class)- Returns:
- The same builder
-
with
public ELKIBuilder<T> with(java.lang.String opt, java.lang.Object value)
Add an option to the builder.- Parameters:
opt
- Option ID (usually found in the Parameterizer class)value
- Value- Returns:
- The same builder
-
with
public ELKIBuilder<T> with(java.lang.String opt)
Add a flag to the builder.- Parameters:
opt
- Option ID (usually found in the Parameterizer class)- Returns:
- The same builder
-
build
public <C extends T> C build()
Instantiate, consuming the parameter list.This will throw an
AbortException
if the parameters are incomplete, orbuild()
is called twice.We lose some type safety here, for convenience. The type
<C>
is meant to be<T>
with generics added only, which is necessary because generics are implemented by erasure in Java.- Type Parameters:
C
- Output type- Returns:
- Instance
-
-