samples/apifest1/day2/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/day2/inputandoperation/src/org/netbeans/apifest/boolcircuit/Factory.java Sat Jun 14 09:52:45 2008 +0200
1.3 @@ -0,0 +1,70 @@
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 + /**
1.25 + * @deprecated use for constants only.. use VariableInput instead..
1.26 + */
1.27 + public static Input createSimpleBooleanInput(boolean value) {
1.28 + return new BooleanInput(value);
1.29 + }
1.30 +
1.31 + public static VariableInput createVariableInput() {
1.32 + return new VariableInput();
1.33 + }
1.34 + /**
1.35 + * @throws IllegalArgument if the boolean operation was already used as input for another operation..
1.36 + * @deprecated
1.37 + */
1.38 + public static Input createOperationBasedBooleanInput(Operation op) throws IllegalArgumentException {
1.39 + assert op != null;
1.40 + if (op.isUsed()) {
1.41 + throw new IllegalArgumentException("Cannot use a single operation repeatedly.");
1.42 + }
1.43 + op.markOperationAsUsed();
1.44 + return new OperationInput(op);
1.45 + }
1.46 +
1.47 + /**
1.48 + * WTF, just make another reasonable sounding factory method now that we have reals..
1.49 + */
1.50 +
1.51 + public static Input createOperationBasedInput(Operation op) throws IllegalArgumentException {
1.52 + return createOperationBasedBooleanInput(op);
1.53 + }
1.54 +
1.55 + public static Operation createAndOperation(Input one, Input two) {
1.56 + assert one != null;
1.57 + assert two != null;
1.58 + return new AndOperation(one, two);
1.59 + }
1.60 +
1.61 + public static Operation createOrOperation(Input one, Input two) {
1.62 + assert one != null;
1.63 + assert two != null;
1.64 + return new OrOperation(one, two);
1.65 + }
1.66 +
1.67 + public static Operation createNotOperation(Input one) {
1.68 + assert one != null;
1.69 + return new NotOperation(one);
1.70 + }
1.71 +
1.72 +
1.73 +}