samples/apifest1/day1/inputandoperation/src/org/netbeans/apifest/boolcircuit/Factory.java
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/apifest1/day1/inputandoperation/src/org/netbeans/apifest/boolcircuit/Factory.java Sat Jun 14 09:52:45 2008 +0200
1.3 @@ -0,0 +1,55 @@
1.4 +/*
1.5 + * Factory.java
1.6 + *
1.7 + * Created on July 12, 2006, 2:21 PM
1.8 + *
1.9 + * To change this template, choose Tools | Template Manager
1.10 + * and open the template in the editor.
1.11 + */
1.12 +
1.13 +package org.netbeans.apifest.boolcircuit;
1.14 +
1.15 +/**
1.16 + *
1.17 + */
1.18 +public class Factory {
1.19 +
1.20 + /** Creates a new instance of Factory */
1.21 + private Factory() {
1.22 + }
1.23 +
1.24 + public static Input createSimpleBooleanInput(boolean value) {
1.25 + return new BooleanInput(value);
1.26 + }
1.27 +
1.28 + /**
1.29 + * @throws IllegalArgument if the boolean operation was already used as input for another operation..
1.30 + */
1.31 + public static Input createOperationBasedBooleanInput(Operation op) throws IllegalArgumentException {
1.32 + assert op != null;
1.33 + if (op.isUsed()) {
1.34 + throw new IllegalArgumentException("Cannot use a single operation repeatedly.");
1.35 + }
1.36 + op.markOperationAsUsed();
1.37 + return new OperationInput(op);
1.38 + }
1.39 +
1.40 + public static Operation createAndOperation(Input one, Input two) {
1.41 + assert one != null;
1.42 + assert two != null;
1.43 + return new AndOperation(one, two);
1.44 + }
1.45 +
1.46 + public static Operation createOrOperation(Input one, Input two) {
1.47 + assert one != null;
1.48 + assert two != null;
1.49 + return new OrOperation(one, two);
1.50 + }
1.51 +
1.52 + public static Operation createNotOperation(Input one) {
1.53 + assert one != null;
1.54 + return new NotOperation(one);
1.55 + }
1.56 +
1.57 +
1.58 +}