| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| BooleanResultFunction |
|
| 5.0;5 |
| 1 | package org.jscsi.target.settings; | |
| 2 | ||
| 3 | ||
| 4 | import org.jscsi.target.settings.entry.BooleanEntry; | |
| 5 | ||
| 6 | ||
| 7 | /** | |
| 8 | * {@link BooleanResultFunction}s are used by instances of{@link BooleanEntry} during the negotiation of boolean | |
| 9 | * parameters. | |
| 10 | * <p> | |
| 11 | * They determine a negotiation outcome based on a logical <code>AND</code> or <code>OR</code> operation. | |
| 12 | * | |
| 13 | * @author Andreas Ergenzinger | |
| 14 | */ | |
| 15 | 0 | public enum BooleanResultFunction { |
| 16 | /** | |
| 17 | * The negotiation result will be <code>true</code> only if both initiator and target support that value. | |
| 18 | */ | |
| 19 | 0 | AND, |
| 20 | /** | |
| 21 | * The negotiation result will be <code>true</code> only if either the initiator or the target support that value. | |
| 22 | */ | |
| 23 | 0 | OR; |
| 24 | ||
| 25 | /** | |
| 26 | * Performs a logical <code>AND</code> or <code>OR</code> operation on the two parameters and returns the result. | |
| 27 | * The type of the operation depends on the value of this {@link BooleanResultFunction}. | |
| 28 | * | |
| 29 | * @param a the first boolean value | |
| 30 | * @param b the second boolean value | |
| 31 | * @return the result of a logical <code>AND</code> or <code>OR</code> operation. | |
| 32 | */ | |
| 33 | public final boolean getResult (final boolean a, final boolean b) { | |
| 34 | 0 | if (this == AND) return a && b; |
| 35 | 0 | return a || b; |
| 36 | } | |
| 37 | } |