|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object hu.birot.OTKit.dataType.violation.Violation hu.birot.OTKit.dataType.violation.BooleanViolation
public class BooleanViolation
Violation with Boolean values (true or false). Value true
is better than false
.
Their difference is -1.
Value true
is better than false
, but not vice versa:
v1 v2 v1.betterEqual(v2)
false false true
false true false
true false true
true true true
Value false
minus value true
is 1, and vice versa it gives -1:
v1 v2 v1.difference(v2)
false false 0
false true 1
true false -1
true true 0
For efficiency, the use of the static method v
is highly
recommended (for instance, in the definition of constraints) instead of the standard
constructor.
Violation
Field Summary | |
---|---|
static BooleanViolation |
FALSE
The boolean violation with value false . |
static BooleanViolation |
TRUE
The boolean violation with value true . |
Fields inherited from class hu.birot.OTKit.dataType.violation.Violation |
---|
thisclass |
Constructor Summary | |
---|---|
BooleanViolation(boolean v)
Construct a new boolean violation, whose value is v . |
Method Summary | |
---|---|
boolean |
betterEqual(Violation v)
Compares this violation to (boolean) violation v : returns whether
this is better than or equal to v . |
BooleanViolation |
clone()
Return a new BooleanViolatio with the same boolean value. |
double |
difference(Violation v)
Computes the difference of this violation and of the (boolean) violation v
("this – v"). |
boolean |
equals(java.lang.Object o)
This violation is equal to object o , if and only if o is also
a BooleanViolation with the same boolean value. |
int |
hashCode()
A hash code for the violation. |
java.lang.String |
toString()
String representation of the violation. |
static BooleanViolation |
v(boolean v)
"Quick constructor". |
java.lang.Boolean |
value()
Return the actual (boolean) value represented by this BooleanViolation. |
Methods inherited from class hu.birot.OTKit.dataType.violation.Violation |
---|
isBetter, isEqual, notComparable |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final BooleanViolation TRUE
true
.
public static final BooleanViolation FALSE
false
.
Constructor Detail |
---|
public BooleanViolation(boolean v)
v
.
v
- Boolean value of the new BooleanViolation
to be constructed.Method Detail |
---|
public java.lang.Boolean value()
value
in class Violation
IntegerViolation.value()
,
FloatViolation.value()
public static BooleanViolation v(boolean v)
"Quick constructor". Returns the violation with value v
that
has been already constructed earlier: either BooleanViolation.TRUE
or BooleanViolation.FALSE
.
With equal arguments, this method always returns the same violation; that is,
not only equal violations, with respect to the equals
method.
Subsequently, several methods comparing two violations run more efficiently,
and less time is spent on constructing new violations, and then on collecting garbage.
Therefore it is recommended to use this static method in the definition of
constraints, and not the standard constructor of the violations.
v
- Value of the violation to be returned.
v
, the only one constructed.TRUE
,
FALSE
public BooleanViolation clone()
clone
in class Violation
public boolean betterEqual(Violation v)
Compares this violation to (boolean) violation v
: returns whether
this is better than or equal to v
.
Value true
is better than false
, but not vice versa:
v1 v2 v1.betterEqual(v2)
false false true
false true false
true false true
true true true
Consequently, v1.betterEqual(v2)
equals the implication
v2 -> v1
, which is the same as the expression v1.value() || !v2.value()
.
If v
is not a BooleanViolation
,
then false
is returned.
If a constraint assigns violations of type
BooleanViolation
, then – as explained in the introduction to the abstract
class Violation
– all candidates must be assigned such violations. Consequently,
in practice this method receives only violations of the same type as its argument.
betterEqual
in class Violation
v
- boolean violation to which this violation is compared.
Violation
,
Violation.betterEqual(Violation)
public double difference(Violation v)
Computes the difference of this violation and of the (boolean) violation v
("this – v").
Value false
minus value true
is 1, and vice versa it gives -1:
v1 v2 v1.difference(v2)
false false 0
false true 1
true false -1
true true 0
The second violation must also be boolean. If a constraint assigns violations of type
BooleanViolation
, then – as explained in the introduction to the abstract
class Violation
– all candidates must be assigned such violations. Consequently,
in practice this method receives only violations of the same type as its argument.
difference
in class Violation
v
- the subtrahend, by which this violation is "diminished".
Violation
,
Violation.difference(Violation)
public boolean equals(java.lang.Object o)
o
, if and only if o
is also
a BooleanViolation with the same boolean value.
equals
in class Violation
o
- Object to be compared to this violation.
public java.lang.String toString()
toString
in class Violation
""+this.value()
.public int hashCode()
hashCode
in class Violation
true
, and 0 if value is false
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |