Renaming Progress to ProgressStateful
authorJaroslav Tulach <jtulach@netbeans.org>
Sun, 02 May 2010 14:35:48 +0200
changeset 350b8edf9de56c5
parent 349 414d979b20b9
child 351 efecc4bc0321
Renaming Progress to ProgressStateful
samples/stateful/src/org/apidesign/stateful/api/Progress.java
samples/stateful/src/org/apidesign/stateful/api/ProgressStateful.java
samples/stateful/test/org/apidesign/stateful/api/ProgressStatefulTest.java
samples/stateful/test/org/apidesign/stateful/api/ProgressTest.java
     1.1 --- a/samples/stateful/src/org/apidesign/stateful/api/Progress.java	Sun May 02 14:34:48 2010 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,53 +0,0 @@
     1.4 -package org.apidesign.stateful.api;
     1.5 -
     1.6 -/** API for notifying progress.
     1.7 - *
     1.8 - * @author Jaroslav Tulach <jtulach@netbeans.org>
     1.9 - */
    1.10 -// BEGIN: progress.api
    1.11 -public abstract class Progress {
    1.12 -    public static Progress create(String name) {
    1.13 -        return createImpl(name);
    1.14 -    }
    1.15 -    public abstract void start(int totalAmount);
    1.16 -    public abstract void progress(int howMuch);
    1.17 -    public abstract void finish();
    1.18 -    // FINISH: progress.api
    1.19 -
    1.20 -    Progress() {
    1.21 -    }
    1.22 -    
    1.23 -    private static Progress createImpl(String name) {
    1.24 -        return new Impl(name);
    1.25 -    }
    1.26 -
    1.27 -    private static final class Impl extends Progress {
    1.28 -        private final String name;
    1.29 -        private int total = -1;
    1.30 -        private int current;
    1.31 -
    1.32 -        public Impl(String name) {
    1.33 -            this.name = name;
    1.34 -        }
    1.35 -
    1.36 -        @Override
    1.37 -        public void start(int totalAmount) {
    1.38 -            total = totalAmount;
    1.39 -        }
    1.40 -
    1.41 -        @Override
    1.42 -        public void progress(int howMuch) {
    1.43 -            if (total == -1) {
    1.44 -                throw new IllegalStateException("Call start first!");
    1.45 -            }
    1.46 -            current = howMuch;
    1.47 -        }
    1.48 -
    1.49 -        @Override
    1.50 -        public void finish() {
    1.51 -            total = -1;
    1.52 -            current = 0;
    1.53 -        }
    1.54 -
    1.55 -    }
    1.56 -}
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/samples/stateful/src/org/apidesign/stateful/api/ProgressStateful.java	Sun May 02 14:35:48 2010 +0200
     2.3 @@ -0,0 +1,53 @@
     2.4 +package org.apidesign.stateful.api;
     2.5 +
     2.6 +/** API for notifying progress.
     2.7 + *
     2.8 + * @author Jaroslav Tulach <jtulach@netbeans.org>
     2.9 + */
    2.10 +// BEGIN: progress.api
    2.11 +public abstract class ProgressStateful {
    2.12 +    public static ProgressStateful create(String name) {
    2.13 +        return createImpl(name);
    2.14 +    }
    2.15 +    public abstract void start(int totalAmount);
    2.16 +    public abstract void progress(int howMuch);
    2.17 +    public abstract void finish();
    2.18 +    // FINISH: progress.api
    2.19 +
    2.20 +    ProgressStateful() {
    2.21 +    }
    2.22 +    
    2.23 +    private static ProgressStateful createImpl(String name) {
    2.24 +        return new Impl(name);
    2.25 +    }
    2.26 +
    2.27 +    private static final class Impl extends ProgressStateful {
    2.28 +        private final String name;
    2.29 +        private int total = -1;
    2.30 +        private int current;
    2.31 +
    2.32 +        public Impl(String name) {
    2.33 +            this.name = name;
    2.34 +        }
    2.35 +
    2.36 +        @Override
    2.37 +        public void start(int totalAmount) {
    2.38 +            total = totalAmount;
    2.39 +        }
    2.40 +
    2.41 +        @Override
    2.42 +        public void progress(int howMuch) {
    2.43 +            if (total == -1) {
    2.44 +                throw new IllegalStateException("Call start first!");
    2.45 +            }
    2.46 +            current = howMuch;
    2.47 +        }
    2.48 +
    2.49 +        @Override
    2.50 +        public void finish() {
    2.51 +            total = -1;
    2.52 +            current = 0;
    2.53 +        }
    2.54 +
    2.55 +    }
    2.56 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/samples/stateful/test/org/apidesign/stateful/api/ProgressStatefulTest.java	Sun May 02 14:35:48 2010 +0200
     3.3 @@ -0,0 +1,25 @@
     3.4 +package org.apidesign.stateful.api;
     3.5 +
     3.6 +import junit.framework.TestCase;
     3.7 +
     3.8 +public class ProgressStatefulTest extends TestCase {
     3.9 +    
    3.10 +    public ProgressStatefulTest(String testName) {
    3.11 +        super(testName);
    3.12 +    }
    3.13 +
    3.14 +    public void testProgressWithoutStart() {
    3.15 +        try {
    3.16 +            // BEGIN: progress.wrong.order
    3.17 +            ProgressStateful p = ProgressStateful.create("WrongOrder");
    3.18 +            p.progress(10);
    3.19 +            p.finish();
    3.20 +            // END: progress.wrong.order
    3.21 +            
    3.22 +            fail("Calling progress without start yields an exception!?");
    3.23 +        } catch (IllegalStateException ex) {
    3.24 +            // OK
    3.25 +        }
    3.26 +    }
    3.27 +
    3.28 +}
     4.1 --- a/samples/stateful/test/org/apidesign/stateful/api/ProgressTest.java	Sun May 02 14:34:48 2010 +0200
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,25 +0,0 @@
     4.4 -package org.apidesign.stateful.api;
     4.5 -
     4.6 -import junit.framework.TestCase;
     4.7 -
     4.8 -public class ProgressTest extends TestCase {
     4.9 -    
    4.10 -    public ProgressTest(String testName) {
    4.11 -        super(testName);
    4.12 -    }
    4.13 -
    4.14 -    public void testProgressWithoutStart() {
    4.15 -        try {
    4.16 -            // BEGIN: progress.wrong.order
    4.17 -            Progress p = Progress.create("WrongOrder");
    4.18 -            p.progress(10);
    4.19 -            p.finish();
    4.20 -            // END: progress.wrong.order
    4.21 -            
    4.22 -            fail("Calling progress without start yields an exception!?");
    4.23 -        } catch (IllegalStateException ex) {
    4.24 -            // OK
    4.25 -        }
    4.26 -    }
    4.27 -
    4.28 -}