001/** 002 * The MIT License (MIT) 003 * 004 * Copyright (c) 2015-2016 decimal4j (tools4j), Marco Terzer 005 * 006 * Permission is hereby granted, free of charge, to any person obtaining a copy 007 * of this software and associated documentation files (the "Software"), to deal 008 * in the Software without restriction, including without limitation the rights 009 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 010 * copies of the Software, and to permit persons to whom the Software is 011 * furnished to do so, subject to the following conditions: 012 * 013 * The above copyright notice and this permission notice shall be included in all 014 * copies or substantial portions of the Software. 015 * 016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 018 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 019 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 022 * SOFTWARE. 023 */ 024package org.decimal4j.exact; 025 026import java.util.Objects; 027 028import org.decimal4j.api.Decimal; 029import org.decimal4j.immutable.Decimal0f; 030import org.decimal4j.immutable.Decimal1f; 031import org.decimal4j.immutable.Decimal2f; 032import org.decimal4j.immutable.Decimal3f; 033import org.decimal4j.immutable.Decimal4f; 034import org.decimal4j.immutable.Decimal5f; 035import org.decimal4j.immutable.Decimal6f; 036import org.decimal4j.immutable.Decimal7f; 037import org.decimal4j.immutable.Decimal8f; 038import org.decimal4j.immutable.Decimal9f; 039import org.decimal4j.immutable.Decimal10f; 040import org.decimal4j.immutable.Decimal11f; 041import org.decimal4j.immutable.Decimal12f; 042import org.decimal4j.immutable.Decimal13f; 043import org.decimal4j.immutable.Decimal14f; 044import org.decimal4j.immutable.Decimal15f; 045import org.decimal4j.immutable.Decimal16f; 046import org.decimal4j.immutable.Decimal17f; 047import org.decimal4j.immutable.Decimal18f; 048import org.decimal4j.mutable.MutableDecimal0f; 049import org.decimal4j.mutable.MutableDecimal1f; 050import org.decimal4j.mutable.MutableDecimal2f; 051import org.decimal4j.mutable.MutableDecimal3f; 052import org.decimal4j.mutable.MutableDecimal4f; 053import org.decimal4j.mutable.MutableDecimal5f; 054import org.decimal4j.mutable.MutableDecimal6f; 055import org.decimal4j.mutable.MutableDecimal8f; 056import org.decimal4j.mutable.MutableDecimal9f; 057import org.decimal4j.mutable.MutableDecimal10f; 058import org.decimal4j.mutable.MutableDecimal11f; 059import org.decimal4j.scale.Scale7f; 060 061/** 062 * A {@code Multipliable7f} encapsulates a Decimal of scale 7 and facilitates 063 * exact typed multiplication. The multipliable object acts as first factor in the multiplication 064 * and provides a set of overloaded methods for different scales. Each one of those methods 065 * delivers a different result scale which represents the appropriate scale for the product of 066 * an exact multiplication. 067 * <p> 068 * A {@code Multipliable7f} object is returned by {@link Decimal7f#multiplyExact()}, 069 * hence an exact typed multiplication can be written as: 070 * <pre> 071 * Decimal7f value = ... //some value 072 * Decimal9f product = value.multiplyExact().by(Decimal2f.FIVE); 073 * </pre> 074 */ 075public final class Multipliable7f { 076 077 private final Decimal<Scale7f> value; 078 079 /** 080 * Constructor with Decimal value to be encapsulated. 081 * @param value the decimal value to be wrapped as a multipliable object 082 */ 083 public Multipliable7f(Decimal<Scale7f> value) { 084 this.value = Objects.requireNonNull(value, "value cannot be null"); 085 } 086 087 /** 088 * Returns the value underlying this Multipliable7f. 089 * @return the Decimal value wrapped by this multipliable object 090 */ 091 public Decimal<Scale7f> getValue() { 092 return value; 093 } 094 095 /** 096 * Returns a {@code Decimal} whose value is <tt>(this<sup>2</sup>)</tt>. The 097 * result is exact and has scale 14 which is twice the scale of 098 * the Decimal that this multipliable object represents. An 099 * {@link ArithmeticException} is thrown if the product is out of the 100 * possible range for a {@code Decimal14f}. 101 * <p> 102 * Note that the result is <i>always</i> a new instance. 103 * 104 * @return <tt>(this * this)</tt> 105 * @throws ArithmeticException 106 * if an overflow occurs and product is out of the possible 107 * range for a {@code Decimal14f} 108 */ 109 public Decimal14f square() { 110 return by(this.value); 111 } 112 113 /** 114 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 115 * result is exact and has scale 14 which is the sum of the scales 116 * of the Decimal that this multipliable object represents and the scale of 117 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 118 * product is out of the possible range for a {@code Decimal14f}. 119 * <p> 120 * Note that the result is <i>always</i> a new instance. 121 * 122 * @param factor 123 * the factor to multiply with the Decimal that this multipliable represents 124 * @return <tt>(this * factor)</tt> 125 * @throws ArithmeticException 126 * if an overflow occurs and product is out of the possible 127 * range for a {@code Decimal14f} 128 */ 129 public Decimal14f by(Decimal<Scale7f> factor) { 130 return Decimal14f.valueOf(this.value.multiplyExact(factor)); 131 } 132 133 /** 134 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 135 * result is exact and has scale 7 which is the sum of the scales 136 * of the Decimal that this multipliable object represents and the scale of 137 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 138 * product is out of the possible range for a {@code Decimal7f}. 139 * <p> 140 * Note that the result is <i>always</i> a new instance. 141 * 142 * @param factor 143 * the factor to multiply with the Decimal that this multipliable represents 144 * @return <tt>(this * factor)</tt> 145 * @throws ArithmeticException 146 * if an overflow occurs and product is out of the possible 147 * range for a {@code Decimal7f} 148 */ 149 public Decimal7f by(Decimal0f factor) { 150 return Decimal7f.valueOf(this.value.multiplyExact(factor)); 151 } 152 /** 153 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 154 * result is exact and has scale 7 which is the sum of the scales 155 * of the Decimal that this multipliable object represents and the scale of 156 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 157 * product is out of the possible range for a {@code Decimal7f}. 158 * <p> 159 * Note that the result is <i>always</i> a new instance. 160 * 161 * @param factor 162 * the factor to multiply with the Decimal that this multipliable represents 163 * @return <tt>(this * factor)</tt> 164 * @throws ArithmeticException 165 * if an overflow occurs and product is out of the possible 166 * range for a {@code Decimal7f} 167 */ 168 public Decimal7f by(MutableDecimal0f factor) { 169 return Decimal7f.valueOf(this.value.multiplyExact(factor)); 170 } 171 172 /** 173 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 174 * result is exact and has scale 8 which is the sum of the scales 175 * of the Decimal that this multipliable object represents and the scale of 176 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 177 * product is out of the possible range for a {@code Decimal8f}. 178 * <p> 179 * Note that the result is <i>always</i> a new instance. 180 * 181 * @param factor 182 * the factor to multiply with the Decimal that this multipliable represents 183 * @return <tt>(this * factor)</tt> 184 * @throws ArithmeticException 185 * if an overflow occurs and product is out of the possible 186 * range for a {@code Decimal8f} 187 */ 188 public Decimal8f by(Decimal1f factor) { 189 return Decimal8f.valueOf(this.value.multiplyExact(factor)); 190 } 191 /** 192 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 193 * result is exact and has scale 8 which is the sum of the scales 194 * of the Decimal that this multipliable object represents and the scale of 195 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 196 * product is out of the possible range for a {@code Decimal8f}. 197 * <p> 198 * Note that the result is <i>always</i> a new instance. 199 * 200 * @param factor 201 * the factor to multiply with the Decimal that this multipliable represents 202 * @return <tt>(this * factor)</tt> 203 * @throws ArithmeticException 204 * if an overflow occurs and product is out of the possible 205 * range for a {@code Decimal8f} 206 */ 207 public Decimal8f by(MutableDecimal1f factor) { 208 return Decimal8f.valueOf(this.value.multiplyExact(factor)); 209 } 210 211 /** 212 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 213 * result is exact and has scale 9 which is the sum of the scales 214 * of the Decimal that this multipliable object represents and the scale of 215 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 216 * product is out of the possible range for a {@code Decimal9f}. 217 * <p> 218 * Note that the result is <i>always</i> a new instance. 219 * 220 * @param factor 221 * the factor to multiply with the Decimal that this multipliable represents 222 * @return <tt>(this * factor)</tt> 223 * @throws ArithmeticException 224 * if an overflow occurs and product is out of the possible 225 * range for a {@code Decimal9f} 226 */ 227 public Decimal9f by(Decimal2f factor) { 228 return Decimal9f.valueOf(this.value.multiplyExact(factor)); 229 } 230 /** 231 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 232 * result is exact and has scale 9 which is the sum of the scales 233 * of the Decimal that this multipliable object represents and the scale of 234 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 235 * product is out of the possible range for a {@code Decimal9f}. 236 * <p> 237 * Note that the result is <i>always</i> a new instance. 238 * 239 * @param factor 240 * the factor to multiply with the Decimal that this multipliable represents 241 * @return <tt>(this * factor)</tt> 242 * @throws ArithmeticException 243 * if an overflow occurs and product is out of the possible 244 * range for a {@code Decimal9f} 245 */ 246 public Decimal9f by(MutableDecimal2f factor) { 247 return Decimal9f.valueOf(this.value.multiplyExact(factor)); 248 } 249 250 /** 251 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 252 * result is exact and has scale 10 which is the sum of the scales 253 * of the Decimal that this multipliable object represents and the scale of 254 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 255 * product is out of the possible range for a {@code Decimal10f}. 256 * <p> 257 * Note that the result is <i>always</i> a new instance. 258 * 259 * @param factor 260 * the factor to multiply with the Decimal that this multipliable represents 261 * @return <tt>(this * factor)</tt> 262 * @throws ArithmeticException 263 * if an overflow occurs and product is out of the possible 264 * range for a {@code Decimal10f} 265 */ 266 public Decimal10f by(Decimal3f factor) { 267 return Decimal10f.valueOf(this.value.multiplyExact(factor)); 268 } 269 /** 270 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 271 * result is exact and has scale 10 which is the sum of the scales 272 * of the Decimal that this multipliable object represents and the scale of 273 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 274 * product is out of the possible range for a {@code Decimal10f}. 275 * <p> 276 * Note that the result is <i>always</i> a new instance. 277 * 278 * @param factor 279 * the factor to multiply with the Decimal that this multipliable represents 280 * @return <tt>(this * factor)</tt> 281 * @throws ArithmeticException 282 * if an overflow occurs and product is out of the possible 283 * range for a {@code Decimal10f} 284 */ 285 public Decimal10f by(MutableDecimal3f factor) { 286 return Decimal10f.valueOf(this.value.multiplyExact(factor)); 287 } 288 289 /** 290 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 291 * result is exact and has scale 11 which is the sum of the scales 292 * of the Decimal that this multipliable object represents and the scale of 293 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 294 * product is out of the possible range for a {@code Decimal11f}. 295 * <p> 296 * Note that the result is <i>always</i> a new instance. 297 * 298 * @param factor 299 * the factor to multiply with the Decimal that this multipliable represents 300 * @return <tt>(this * factor)</tt> 301 * @throws ArithmeticException 302 * if an overflow occurs and product is out of the possible 303 * range for a {@code Decimal11f} 304 */ 305 public Decimal11f by(Decimal4f factor) { 306 return Decimal11f.valueOf(this.value.multiplyExact(factor)); 307 } 308 /** 309 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 310 * result is exact and has scale 11 which is the sum of the scales 311 * of the Decimal that this multipliable object represents and the scale of 312 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 313 * product is out of the possible range for a {@code Decimal11f}. 314 * <p> 315 * Note that the result is <i>always</i> a new instance. 316 * 317 * @param factor 318 * the factor to multiply with the Decimal that this multipliable represents 319 * @return <tt>(this * factor)</tt> 320 * @throws ArithmeticException 321 * if an overflow occurs and product is out of the possible 322 * range for a {@code Decimal11f} 323 */ 324 public Decimal11f by(MutableDecimal4f factor) { 325 return Decimal11f.valueOf(this.value.multiplyExact(factor)); 326 } 327 328 /** 329 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 330 * result is exact and has scale 12 which is the sum of the scales 331 * of the Decimal that this multipliable object represents and the scale of 332 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 333 * product is out of the possible range for a {@code Decimal12f}. 334 * <p> 335 * Note that the result is <i>always</i> a new instance. 336 * 337 * @param factor 338 * the factor to multiply with the Decimal that this multipliable represents 339 * @return <tt>(this * factor)</tt> 340 * @throws ArithmeticException 341 * if an overflow occurs and product is out of the possible 342 * range for a {@code Decimal12f} 343 */ 344 public Decimal12f by(Decimal5f factor) { 345 return Decimal12f.valueOf(this.value.multiplyExact(factor)); 346 } 347 /** 348 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 349 * result is exact and has scale 12 which is the sum of the scales 350 * of the Decimal that this multipliable object represents and the scale of 351 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 352 * product is out of the possible range for a {@code Decimal12f}. 353 * <p> 354 * Note that the result is <i>always</i> a new instance. 355 * 356 * @param factor 357 * the factor to multiply with the Decimal that this multipliable represents 358 * @return <tt>(this * factor)</tt> 359 * @throws ArithmeticException 360 * if an overflow occurs and product is out of the possible 361 * range for a {@code Decimal12f} 362 */ 363 public Decimal12f by(MutableDecimal5f factor) { 364 return Decimal12f.valueOf(this.value.multiplyExact(factor)); 365 } 366 367 /** 368 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 369 * result is exact and has scale 13 which is the sum of the scales 370 * of the Decimal that this multipliable object represents and the scale of 371 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 372 * product is out of the possible range for a {@code Decimal13f}. 373 * <p> 374 * Note that the result is <i>always</i> a new instance. 375 * 376 * @param factor 377 * the factor to multiply with the Decimal that this multipliable represents 378 * @return <tt>(this * factor)</tt> 379 * @throws ArithmeticException 380 * if an overflow occurs and product is out of the possible 381 * range for a {@code Decimal13f} 382 */ 383 public Decimal13f by(Decimal6f factor) { 384 return Decimal13f.valueOf(this.value.multiplyExact(factor)); 385 } 386 /** 387 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 388 * result is exact and has scale 13 which is the sum of the scales 389 * of the Decimal that this multipliable object represents and the scale of 390 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 391 * product is out of the possible range for a {@code Decimal13f}. 392 * <p> 393 * Note that the result is <i>always</i> a new instance. 394 * 395 * @param factor 396 * the factor to multiply with the Decimal that this multipliable represents 397 * @return <tt>(this * factor)</tt> 398 * @throws ArithmeticException 399 * if an overflow occurs and product is out of the possible 400 * range for a {@code Decimal13f} 401 */ 402 public Decimal13f by(MutableDecimal6f factor) { 403 return Decimal13f.valueOf(this.value.multiplyExact(factor)); 404 } 405 406 /** 407 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 408 * result is exact and has scale 15 which is the sum of the scales 409 * of the Decimal that this multipliable object represents and the scale of 410 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 411 * product is out of the possible range for a {@code Decimal15f}. 412 * <p> 413 * Note that the result is <i>always</i> a new instance. 414 * 415 * @param factor 416 * the factor to multiply with the Decimal that this multipliable represents 417 * @return <tt>(this * factor)</tt> 418 * @throws ArithmeticException 419 * if an overflow occurs and product is out of the possible 420 * range for a {@code Decimal15f} 421 */ 422 public Decimal15f by(Decimal8f factor) { 423 return Decimal15f.valueOf(this.value.multiplyExact(factor)); 424 } 425 /** 426 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 427 * result is exact and has scale 15 which is the sum of the scales 428 * of the Decimal that this multipliable object represents and the scale of 429 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 430 * product is out of the possible range for a {@code Decimal15f}. 431 * <p> 432 * Note that the result is <i>always</i> a new instance. 433 * 434 * @param factor 435 * the factor to multiply with the Decimal that this multipliable represents 436 * @return <tt>(this * factor)</tt> 437 * @throws ArithmeticException 438 * if an overflow occurs and product is out of the possible 439 * range for a {@code Decimal15f} 440 */ 441 public Decimal15f by(MutableDecimal8f factor) { 442 return Decimal15f.valueOf(this.value.multiplyExact(factor)); 443 } 444 445 /** 446 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 447 * result is exact and has scale 16 which is the sum of the scales 448 * of the Decimal that this multipliable object represents and the scale of 449 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 450 * product is out of the possible range for a {@code Decimal16f}. 451 * <p> 452 * Note that the result is <i>always</i> a new instance. 453 * 454 * @param factor 455 * the factor to multiply with the Decimal that this multipliable represents 456 * @return <tt>(this * factor)</tt> 457 * @throws ArithmeticException 458 * if an overflow occurs and product is out of the possible 459 * range for a {@code Decimal16f} 460 */ 461 public Decimal16f by(Decimal9f factor) { 462 return Decimal16f.valueOf(this.value.multiplyExact(factor)); 463 } 464 /** 465 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 466 * result is exact and has scale 16 which is the sum of the scales 467 * of the Decimal that this multipliable object represents and the scale of 468 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 469 * product is out of the possible range for a {@code Decimal16f}. 470 * <p> 471 * Note that the result is <i>always</i> a new instance. 472 * 473 * @param factor 474 * the factor to multiply with the Decimal that this multipliable represents 475 * @return <tt>(this * factor)</tt> 476 * @throws ArithmeticException 477 * if an overflow occurs and product is out of the possible 478 * range for a {@code Decimal16f} 479 */ 480 public Decimal16f by(MutableDecimal9f factor) { 481 return Decimal16f.valueOf(this.value.multiplyExact(factor)); 482 } 483 484 /** 485 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 486 * result is exact and has scale 17 which is the sum of the scales 487 * of the Decimal that this multipliable object represents and the scale of 488 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 489 * product is out of the possible range for a {@code Decimal17f}. 490 * <p> 491 * Note that the result is <i>always</i> a new instance. 492 * 493 * @param factor 494 * the factor to multiply with the Decimal that this multipliable represents 495 * @return <tt>(this * factor)</tt> 496 * @throws ArithmeticException 497 * if an overflow occurs and product is out of the possible 498 * range for a {@code Decimal17f} 499 */ 500 public Decimal17f by(Decimal10f factor) { 501 return Decimal17f.valueOf(this.value.multiplyExact(factor)); 502 } 503 /** 504 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 505 * result is exact and has scale 17 which is the sum of the scales 506 * of the Decimal that this multipliable object represents and the scale of 507 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 508 * product is out of the possible range for a {@code Decimal17f}. 509 * <p> 510 * Note that the result is <i>always</i> a new instance. 511 * 512 * @param factor 513 * the factor to multiply with the Decimal that this multipliable represents 514 * @return <tt>(this * factor)</tt> 515 * @throws ArithmeticException 516 * if an overflow occurs and product is out of the possible 517 * range for a {@code Decimal17f} 518 */ 519 public Decimal17f by(MutableDecimal10f factor) { 520 return Decimal17f.valueOf(this.value.multiplyExact(factor)); 521 } 522 523 /** 524 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 525 * result is exact and has scale 18 which is the sum of the scales 526 * of the Decimal that this multipliable object represents and the scale of 527 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 528 * product is out of the possible range for a {@code Decimal18f}. 529 * <p> 530 * Note that the result is <i>always</i> a new instance. 531 * 532 * @param factor 533 * the factor to multiply with the Decimal that this multipliable represents 534 * @return <tt>(this * factor)</tt> 535 * @throws ArithmeticException 536 * if an overflow occurs and product is out of the possible 537 * range for a {@code Decimal18f} 538 */ 539 public Decimal18f by(Decimal11f factor) { 540 return Decimal18f.valueOf(this.value.multiplyExact(factor)); 541 } 542 /** 543 * Returns a {@code Decimal} whose value is {@code (this * factor)}. The 544 * result is exact and has scale 18 which is the sum of the scales 545 * of the Decimal that this multipliable object represents and the scale of 546 * the {@code factor} argument. An {@link ArithmeticException} is thrown if the 547 * product is out of the possible range for a {@code Decimal18f}. 548 * <p> 549 * Note that the result is <i>always</i> a new instance. 550 * 551 * @param factor 552 * the factor to multiply with the Decimal that this multipliable represents 553 * @return <tt>(this * factor)</tt> 554 * @throws ArithmeticException 555 * if an overflow occurs and product is out of the possible 556 * range for a {@code Decimal18f} 557 */ 558 public Decimal18f by(MutableDecimal11f factor) { 559 return Decimal18f.valueOf(this.value.multiplyExact(factor)); 560 } 561 562 563 /** 564 * Returns a hash code for this <tt>Multipliable7f</tt> which happens to be the 565 * hash code of the underlying {@code Decimal7f} value. 566 * 567 * @return a hash code value for this object 568 * @see Decimal#hashCode() 569 */ 570 @Override 571 public int hashCode() { 572 return value.hashCode(); 573 } 574 575 /** 576 * Compares this Multipliable7f to the specified object. The result is {@code true} 577 * if and only if the argument is a {@code Multipliable7f} with an equal underlying 578 * {@link #getValue() value}. 579 * 580 * @param obj 581 * the object to compare with 582 * @return {@code true} if the argument is a {@code Multipliable7f} and if its value 583 * is equal to this multipliables's value; {@code false} otherwise 584 * @see #getValue() 585 * @see Decimal#equals(Object) 586 */ 587 @Override 588 public boolean equals(Object obj) { 589 if (this == obj) return true; 590 if (obj == null) return false; 591 if (getClass() != obj.getClass()) return false; 592 return value.equals(((Multipliable7f)obj).value); 593 } 594 595 /** 596 * Returns a string representation of this {@code Multipliable7f} which is 597 * simply the string representation of the underlying Decimal {@link #getValue() value}. 598 * 599 * @return a {@code String} Decimal representation of this {@code Multipliable7f}'s 600 * value with all the fraction digits (including trailing zeros) 601 * @see #getValue() 602 * @see Decimal#toString() 603 */ 604 @Override 605 public String toString() { 606 return value.toString(); 607 } 608}