|
18 | 18 | package com.onixbyte.nums.model; |
19 | 19 |
|
20 | 20 | /** |
21 | | - * QuartileBound. |
| 21 | + * A record representing the quartile bounds of a dataset. |
| 22 | + * <p> |
| 23 | + * This class encapsulates the lower and upper bounds of a dataset, which are typically used for detecting outliers in |
| 24 | + * the data. The bounds are calculated based on the interquartile range (IQR) of the dataset. Values below the lower |
| 25 | + * bound or above the upper bound may be considered outliers. |
| 26 | + * <p> |
| 27 | + * Quartile bounds consist of: |
| 28 | + * <ul> |
| 29 | + * <li>{@code lowerBound} - The lower bound of the dataset, typically {@code Q1 - 1.5 * IQR}.</li> |
| 30 | + * <li>{@code upperBound} - The upper bound of the dataset, typically {@code Q3 + 1.5 * IQR}.</li> |
| 31 | + * </ul> |
| 32 | + * </p> |
| 33 | + * <p> |
| 34 | + * Example usage: |
| 35 | + * <pre> |
| 36 | + * QuartileBounds bounds = QuartileBounds.builder() |
| 37 | + * .lowerBound(1.5) |
| 38 | + * .upperBound(7.5) |
| 39 | + * .build(); |
| 40 | + * </pre> |
22 | 41 | * |
23 | | - * @param upperBound |
24 | | - * @param lowerBound |
| 42 | + * @param upperBound the upper bound of the dataset |
| 43 | + * @param lowerBound the lower bound of the dataset |
25 | 44 | * @author zihluwang |
| 45 | + * @version 1.6.5 |
| 46 | + * @since 1.6.5 |
26 | 47 | */ |
27 | 48 | public record QuartileBounds( |
28 | 49 | Double upperBound, |
29 | 50 | Double lowerBound |
30 | 51 | ) { |
31 | 52 |
|
32 | 53 | /** |
33 | | - * Get a builder for {@link QuartileBounds}. |
| 54 | + * Creates a new {@link Builder} instance for building a {@code QuartileBounds} object. |
| 55 | + * <p> |
| 56 | + * The {@link Builder} pattern is used to construct the {@code QuartileBounds} object with optional values for the |
| 57 | + * upper and lower bounds. |
| 58 | + * </p> |
34 | 59 | * |
35 | | - * @return a builder |
| 60 | + * @return a new instance of the {@link Builder} class |
36 | 61 | */ |
37 | 62 | public static Builder builder() { |
38 | 63 | return new Builder(); |
39 | 64 | } |
40 | 65 |
|
| 66 | + /** |
| 67 | + * A builder class for constructing instances of the {@code QuartileBounds} record. |
| 68 | + * <p> |
| 69 | + * The {@link Builder} pattern allows for the step-by-step construction of a {@code QuartileBounds} object, |
| 70 | + * providing a flexible way to set values for the lower and upper bounds. Once the builder has the required values, |
| 71 | + * the {@link #build()} method creates and returns a new {@code QuartileBounds} object. |
| 72 | + * </p> |
| 73 | + * <p> |
| 74 | + * Example usage: |
| 75 | + * <pre> |
| 76 | + * {@code |
| 77 | + * QuartileBounds bounds = QuartileBounds.builder() |
| 78 | + * .lowerBound(1.5) |
| 79 | + * .upperBound(7.5) |
| 80 | + * .build(); |
| 81 | + * } |
| 82 | + * </pre> |
| 83 | + */ |
41 | 84 | public static class Builder { |
42 | 85 | private Double upperBound; |
43 | 86 | private Double lowerBound; |
44 | 87 |
|
| 88 | + /** |
| 89 | + * Private constructor for {@code Builder}, ensuring it can only be instantiated through the |
| 90 | + * {@link QuartileBounds#builder()} method. |
| 91 | + */ |
45 | 92 | private Builder() { |
46 | 93 | } |
47 | 94 |
|
| 95 | + /** |
| 96 | + * Sets the upper bound for the {@code QuartileBounds}. |
| 97 | + * |
| 98 | + * @param upperBound the upper bound of the dataset |
| 99 | + * @return the current {@code Builder} instance, for method chaining |
| 100 | + */ |
48 | 101 | public Builder upperBound(Double upperBound) { |
49 | 102 | this.upperBound = upperBound; |
50 | 103 | return this; |
51 | 104 | } |
52 | 105 |
|
| 106 | + /** |
| 107 | + * Sets the lower bound for the {@code QuartileBounds}. |
| 108 | + * |
| 109 | + * @param lowerBound the lower bound of the dataset |
| 110 | + * @return the current {@code Builder} instance, for method chaining |
| 111 | + */ |
53 | 112 | public Builder lowerBound(Double lowerBound) { |
54 | 113 | this.lowerBound = lowerBound; |
55 | 114 | return this; |
56 | 115 | } |
57 | 116 |
|
| 117 | + /** |
| 118 | + * Builds and returns a new {@code QuartileBounds} instance with the specified upper and lower bounds. |
| 119 | + * |
| 120 | + * @return a new {@code QuartileBounds} object containing the specified bounds |
| 121 | + */ |
58 | 122 | public QuartileBounds build() { |
59 | 123 | return new QuartileBounds(upperBound, lowerBound); |
60 | 124 | } |
|
0 commit comments