isZero() & isOne() introduced to NumericConstraintBase.#191
isZero() & isOne() introduced to NumericConstraintBase.#191DiegoKrupitza wants to merge 2 commits intomaking:developfrom
isZero() & isOne() introduced to NumericConstraintBase.#191Conversation
Checking whether a given number is zero or one is now more pleasent to write and read. It is not longer needed to to use `c -> c.equalTo(0)` or `c -> c.equalTo(1)`.
|
What are the use cases that require this constraint? |
Although using integers as flags is not really good practice, it is sometimes needed due to language-agnostic interfaces. Lets say we have an enum: public enum DeliveryType {
TAKE_AWAY(0),
DINE_IN(1),
STAFF(2);
private int type;
DeliveryType (int type) {
this.type = type;
}
// Method that gets the type variable.
}Lets say we want to validate that the delivery type of a certain request is only In this case it would make more sense to write Furthermore, 0 and 1 are so special numbers in CS that it always gets special treatments (special constants in |
|
Hmmm, it doesn't seem like a valid use case to me. Leave this PR open until further requests come in. |
Checking whether a given number is zero or one is now more pleasant to write and read. It is not longer needed to to use
c -> c.equalTo(0)orc -> c.equalTo(1).