summaryrefslogtreecommitdiff
path: root/src/main/java/sevenUnits/utils/ObjectProduct.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/sevenUnits/utils/ObjectProduct.java')
-rw-r--r--src/main/java/sevenUnits/utils/ObjectProduct.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main/java/sevenUnits/utils/ObjectProduct.java b/src/main/java/sevenUnits/utils/ObjectProduct.java
index 772ff5e..1b8832e 100644
--- a/src/main/java/sevenUnits/utils/ObjectProduct.java
+++ b/src/main/java/sevenUnits/utils/ObjectProduct.java
@@ -33,6 +33,7 @@ import java.util.function.Function;
* @author Adrien Hopkins
* @param <T> type of object that is being multiplied
* @since 2019-10-16
+ * @since v0.3.0
*/
public class ObjectProduct<T> implements Nameable {
/**
@@ -47,6 +48,7 @@ public class ObjectProduct<T> implements Nameable {
* @param <T> type of objects that can be multiplied
* @return empty product
* @since 2019-10-16
+ * @since v0.3.0
*/
public static final <T> ObjectProduct<T> empty() {
return new ObjectProduct<>(new HashMap<>());
@@ -59,6 +61,7 @@ public class ObjectProduct<T> implements Nameable {
* @param map map mapping objects to exponents
* @return object product
* @since 2019-10-16
+ * @since v0.3.0
*/
public static final <T> ObjectProduct<T> fromExponentMapping(
final Map<T, Integer> map) {
@@ -73,6 +76,7 @@ public class ObjectProduct<T> implements Nameable {
* @param <T> type of object contained in returned ObjectProduct
* @return product
* @since 2019-10-16
+ * @since v0.3.0
* @throws NullPointerException if object is null
*/
public static final <T> ObjectProduct<T> oneOf(final T object) {
@@ -87,6 +91,7 @@ public class ObjectProduct<T> implements Nameable {
* treats zero as null, and is immutable.
*
* @since 2019-10-16
+ * @since v0.3.0
*/
final Map<T, Integer> exponents;
@@ -100,6 +105,7 @@ public class ObjectProduct<T> implements Nameable {
*
* @param exponents objects that make up this product
* @since 2019-10-16
+ * @since v0.3.0
*/
ObjectProduct(final Map<T, Integer> exponents) {
this(exponents, NameSymbol.EMPTY);
@@ -111,6 +117,7 @@ public class ObjectProduct<T> implements Nameable {
* @param exponents objects that make up this product
* @param nameSymbol name and symbol of object product
* @since 2019-10-16
+ * @since v0.3.0
*/
ObjectProduct(final Map<T, Integer> exponents, NameSymbol nameSymbol) {
this.exponents = Collections.unmodifiableMap(
@@ -125,6 +132,7 @@ public class ObjectProduct<T> implements Nameable {
* @param other other product
* @return quotient of two products
* @since 2019-10-16
+ * @since v0.3.0
* @throws NullPointerException if other is null
*/
public ObjectProduct<T> dividedBy(final ObjectProduct<T> other) {
@@ -158,6 +166,7 @@ public class ObjectProduct<T> implements Nameable {
/**
* @return immutable map mapping objects to exponents
* @since 2019-10-16
+ * @since v0.3.0
*/
public Map<T, Integer> exponentMap() {
return this.exponents;
@@ -209,6 +218,7 @@ public class ObjectProduct<T> implements Nameable {
* @return true if this product is a single object, i.e. it has one exponent
* of one and no other nonzero exponents
* @since 2019-10-16
+ * @since v0.3.0
*/
public boolean isSingleObject() {
int oneCount = 0;
@@ -229,6 +239,7 @@ public class ObjectProduct<T> implements Nameable {
* @param other other product
* @return product of two products
* @since 2019-10-16
+ * @since v0.3.0
* @throws NullPointerException if other is null
*/
public ObjectProduct<T> times(final ObjectProduct<T> other) {
@@ -254,6 +265,7 @@ public class ObjectProduct<T> implements Nameable {
* @param exponent exponent
* @return result of exponentiation
* @since 2019-10-16
+ * @since v0.3.0
*/
public ObjectProduct<T> toExponent(final int exponent) {
final Map<T, Integer> map = new HashMap<>(this.exponents);
@@ -274,6 +286,7 @@ public class ObjectProduct<T> implements Nameable {
* @return result of exponentiation
*
* @since 2024-08-22
+ * @since v0.3.0
*/
public ObjectProduct<T> toExponentRounded(final double exponent) {
final Map<T, Integer> map = new HashMap<>(this.exponents);
@@ -315,6 +328,7 @@ public class ObjectProduct<T> implements Nameable {
* @param objectToString function to convert objects to strings
* @return string representation of product
* @since 2019-10-16
+ * @since v0.3.0
*/
public String toString(final Function<T, String> objectToString) {
final List<String> positiveStringComponents = new ArrayList<>();
@@ -347,6 +361,7 @@ public class ObjectProduct<T> implements Nameable {
* @return named version of this {@code ObjectProduct}, using data from
* {@code nameSymbol}
* @since 2021-12-15
+ * @since v0.3.0
*/
public ObjectProduct<T> withName(NameSymbol nameSymbol) {
return new ObjectProduct<>(this.exponents, nameSymbol);