Class Metrics.Builder
java.lang.Object
io.github.projectunified.faststats.core.Metrics.Builder
- Enclosing class:
Metrics
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddFeature(Feature feature) Adds a feature to be configured with the submit executor.addFeatures(Collection<Feature> features) Adds a collection of features to be configured with the submit executor.Adds a metric to be collected and submitted.addMetrics(Collection<Metric<?>> metrics) Adds a collection of metrics to be collected and submitted.build()Builds theMetricsinstance.Adds a flush callback to this metrics instance.Sets the platform implementation.scheduler(TaskScheduler scheduler) Sets the task scheduler.serializer(Serializer serializer) Sets the JSON serializer.Sets the submitter.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
platform
Sets the platform implementation.- Parameters:
platform- the platform- Returns:
- this builder instance
-
serializer
Sets the JSON serializer.- Parameters:
serializer- the serializer- Returns:
- this builder instance
-
submitter
Sets the submitter.- Parameters:
submitter- the submitter- Returns:
- this builder instance
-
scheduler
Sets the task scheduler.- Parameters:
scheduler- the task scheduler- Returns:
- this builder instance
-
addMetric
Adds a metric to be collected and submitted.- Parameters:
metric- the metric to add- Returns:
- this builder instance
- Throws:
IllegalArgumentException- if the metric name is invalid or already added
-
addMetrics
Adds a collection of metrics to be collected and submitted.- Parameters:
metrics- the metrics to add- Returns:
- this builder instance
- Throws:
IllegalArgumentException- if a metric name is invalid or already added
-
onFlush
Adds a flush callback to this metrics instance.The callback is invoked after the metrics payload has been accepted by the metrics server, which makes it suitable for resetting counters that accumulate between submissions.
- Parameters:
flush- the flush callback- Returns:
- this builder instance
-
addFeature
Adds a feature to be configured with the submit executor.- Parameters:
feature- the feature to add- Returns:
- this builder instance
-
addFeatures
Adds a collection of features to be configured with the submit executor.- Parameters:
features- the features to add- Returns:
- this builder instance
-
build
Builds theMetricsinstance.- Returns:
- a new Metrics instance
- Throws:
IllegalStateException- if any required fields are missing
-