-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #120 : changed assert check to use compareTo() in BinaryOperati…
…on constructor
- Loading branch information
1 parent
d5ab21d
commit ed92c8a
Showing
1 changed file
with
4 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ | |
* @author Pablo Rodríguez Mier <<a href="mailto:[email protected]">[email protected]</a>> | ||
* @author Adrián González Sieira <<a href="[email protected]">[email protected]</a>> | ||
*/ | ||
public class BinaryOperation<E> implements BinaryFunction<E> { | ||
public class BinaryOperation<E extends Comparable<E>> implements BinaryFunction<E> { | ||
|
||
private E maxElem; | ||
private E identityElem; | ||
|
@@ -45,9 +45,9 @@ public class BinaryOperation<E> implements BinaryFunction<E> { | |
*/ | ||
public BinaryOperation(BinaryFunction<E> operation, E identityElem, E maxElem) { | ||
// Check properties | ||
assert operation.apply(identityElem, maxElem).equals(maxElem); | ||
assert operation.apply(maxElem, identityElem).equals(maxElem); | ||
assert operation.apply(identityElem, identityElem).equals(identityElem); | ||
assert operation.apply(identityElem, maxElem).compareTo(maxElem) == 0; | ||
assert operation.apply(maxElem, identityElem).compareTo(maxElem) == 0; | ||
assert operation.apply(identityElem, identityElem).compareTo(identityElem) == 0; | ||
//Preconditions.checkArgument(operation.apply(identityElem, maxElem).equals(maxElem), "Property error: I x A != A"); | ||
//Preconditions.checkArgument(operation.apply(maxElem, identityElem).equals(maxElem), "Property error: A x I != A"); | ||
//Preconditions.checkArgument(operation.apply(identityElem, identityElem).equals(identityElem), "Property error: I x I != I"); | ||
|