public class SimplePenalizingValidation extends Object implements PenalizingValidation
Modifier and Type | Field and Description |
---|---|
static SimplePenalizingValidation |
PASSED
Constant simple penalizing validation indicating that the validation passed successfully
(
passed() returns true and no penalty is assigned). |
Constructor and Description |
---|
SimplePenalizingValidation(boolean passed,
double penalty)
Create a simple penalizing validation with a given boolean value, indicating
whether the corresponding solution passed validation, and an assigned penalty.
|
Modifier and Type | Method and Description |
---|---|
static SimplePenalizingValidation |
FAILED(double penalty)
Creates a simple penalizing validation indicating that the validation failed, where
the given strictly positive penalty is assigned.
|
double |
getPenalty()
Get the assigned penalty.
|
boolean |
passed()
Get the boolean value specified at construction, indicating whether the corresponding solution
passed validation.
|
String |
toString()
Get a string representation of the validation object.
|
public static final SimplePenalizingValidation PASSED
passed()
returns true
and no penalty is assigned).public SimplePenalizingValidation(boolean passed, double penalty)
passed
is true
the value of penalty
is ignored and the penalty is set to 0. In such case, penalty
can
be set to any value, e.g. -1. If passed
is false
it is
required that penalty
is a strictly positive value.passed
- boolean value, true
if the corresponding solution is validpenalty
- assigned penalty, ignored if passed
is true
IllegalArgumentException
- if passed
is false
but
penalty
is not strictly positivepublic static final SimplePenalizingValidation FAILED(double penalty)
penalty
- assigned penaltypassed()
returns false
and getPenalty()
returns the given strictly positive penaltyIllegalArgumentException
- if penalty
is not strictly positivepublic boolean passed()
true
, getPenalty()
returns 0.0.passed
in interface Validation
true
if the corresponding solution is validpublic double getPenalty()
passed()
returns false
this method returns
the strictly positive penalty specified at construction. Else, it returns 0.0.getPenalty
in interface PenalizingValidation
Copyright © 2016. All rights reserved.