io.nosqlbench.nb.api.annotations.AnnotationBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nb-api Show documentation
Show all versions of nb-api Show documentation
The top level API module for NoSQLBench. This module should have no internal
module dependencies other than the mvn-default module.
All modules within NoSQLBench can safely depend on this module with circular
dependencies. This module provides cross-cutting code infrastracture, such as
path utilities and ways of describing services used between modules.
It is also the transitive aggregation point for system-wide library dependencies
for logging and testing or similar needs.
package io.nosqlbench.nb.api.annotations;
import java.time.ZoneId;
import java.util.LinkedHashMap;
import java.util.TimeZone;
public class AnnotationBuilder implements BuilderFacets.All {
private String session;
private long start;
private long end;
private final LinkedHashMap labels = new LinkedHashMap<>();
private final LinkedHashMap details = new LinkedHashMap<>();
private Layer layer;
private final TimeZone timezone = TimeZone.getTimeZone(ZoneId.of("GMT"));
@Override
public AnnotationBuilder layer(Layer layer) {
this.layer = layer;
this.label("layer", layer.toString());
return this;
}
@Override
public AnnotationBuilder interval(long start, long end) {
start(start);
end(end);
return this;
}
@Override
public AnnotationBuilder now() {
start(System.currentTimeMillis());
end(this.start);
return this;
}
private AnnotationBuilder start(long start) {
this.start = start;
return this;
}
private AnnotationBuilder end(long end) {
this.end = end;
return this;
}
@Override
public AnnotationBuilder at(long at) {
this.start(at);
this.end(at);
return this;
}
@Override
public AnnotationBuilder label(String name, String value) {
this.labels.put(name, value);
return this;
}
@Override
public BuilderFacets.WantsMoreDetailsOrBuild detail(String name, String value) {
this.details.put(name, value);
return this;
}
@Override
public Annotation build() {
return new MutableAnnotation(timezone, session, layer, start, end, labels, details).asReadOnly();
}
@Override
public BuilderFacets.WantsInterval session(String session) {
this.session = session;
return this;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy