author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:52:45 +0200 | |
changeset 52 | 4257f4cf226b |
permissions | -rw-r--r-- |
jtulach@52 | 1 |
/* |
jtulach@52 | 2 |
* Factory.java |
jtulach@52 | 3 |
* |
jtulach@52 | 4 |
* Created on July 12, 2006, 2:21 PM |
jtulach@52 | 5 |
* |
jtulach@52 | 6 |
* To change this template, choose Tools | Template Manager |
jtulach@52 | 7 |
* and open the template in the editor. |
jtulach@52 | 8 |
*/ |
jtulach@52 | 9 |
|
jtulach@52 | 10 |
package org.netbeans.apifest.boolcircuit; |
jtulach@52 | 11 |
|
jtulach@52 | 12 |
/** |
jtulach@52 | 13 |
* |
jtulach@52 | 14 |
*/ |
jtulach@52 | 15 |
public class Factory { |
jtulach@52 | 16 |
|
jtulach@52 | 17 |
/** Creates a new instance of Factory */ |
jtulach@52 | 18 |
private Factory() { |
jtulach@52 | 19 |
} |
jtulach@52 | 20 |
|
jtulach@52 | 21 |
public static Input createSimpleBooleanInput(boolean value) { |
jtulach@52 | 22 |
return new BooleanInput(value); |
jtulach@52 | 23 |
} |
jtulach@52 | 24 |
|
jtulach@52 | 25 |
/** |
jtulach@52 | 26 |
* @throws IllegalArgument if the boolean operation was already used as input for another operation.. |
jtulach@52 | 27 |
*/ |
jtulach@52 | 28 |
public static Input createOperationBasedBooleanInput(Operation op) throws IllegalArgumentException { |
jtulach@52 | 29 |
assert op != null; |
jtulach@52 | 30 |
if (op.isUsed()) { |
jtulach@52 | 31 |
throw new IllegalArgumentException("Cannot use a single operation repeatedly."); |
jtulach@52 | 32 |
} |
jtulach@52 | 33 |
op.markOperationAsUsed(); |
jtulach@52 | 34 |
return new OperationInput(op); |
jtulach@52 | 35 |
} |
jtulach@52 | 36 |
|
jtulach@52 | 37 |
public static Operation createAndOperation(Input one, Input two) { |
jtulach@52 | 38 |
assert one != null; |
jtulach@52 | 39 |
assert two != null; |
jtulach@52 | 40 |
return new AndOperation(one, two); |
jtulach@52 | 41 |
} |
jtulach@52 | 42 |
|
jtulach@52 | 43 |
public static Operation createOrOperation(Input one, Input two) { |
jtulach@52 | 44 |
assert one != null; |
jtulach@52 | 45 |
assert two != null; |
jtulach@52 | 46 |
return new OrOperation(one, two); |
jtulach@52 | 47 |
} |
jtulach@52 | 48 |
|
jtulach@52 | 49 |
public static Operation createNotOperation(Input one) { |
jtulach@52 | 50 |
assert one != null; |
jtulach@52 | 51 |
return new NotOperation(one); |
jtulach@52 | 52 |
} |
jtulach@52 | 53 |
|
jtulach@52 | 54 |
|
jtulach@52 | 55 |
} |