From df9ff7f340a5ab4e07efc613f5f264eeae63d4c7 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Thu, 3 Jul 2014 16:06:47 +0200 Subject: Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74) Code Clean-Up based on our Recommended Settings (jogamp-scripting c47bc86ae2ee268a1f38c5580d11f93d7f8d6e74) - Change non static accesses to static members using declaring type - Change indirect accesses to static members to direct accesses (accesses through subtypes) - Add final modifier to private fields - Add final modifier to method parameters - Add final modifier to local variables - Remove unnecessary casts - Remove unnecessary '$NON-NLS$' tags - Remove trailing white spaces on all lines --- .../com/jogamp/common/util/RingBuffer01Base.java | 154 ++++++++++----------- 1 file changed, 77 insertions(+), 77 deletions(-) (limited to 'src/junit/com/jogamp/common/util/RingBuffer01Base.java') diff --git a/src/junit/com/jogamp/common/util/RingBuffer01Base.java b/src/junit/com/jogamp/common/util/RingBuffer01Base.java index f7e8fcf..ced94dc 100644 --- a/src/junit/com/jogamp/common/util/RingBuffer01Base.java +++ b/src/junit/com/jogamp/common/util/RingBuffer01Base.java @@ -3,14 +3,14 @@ * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, this list * of conditions and the following disclaimer in the documentation and/or other materials * provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR @@ -20,12 +20,12 @@ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * + * * The views and conclusions contained in the software and documentation are those of the * authors and should not be interpreted as representing official policies, either expressed * or implied, of JogAmp Community. */ - + package com.jogamp.common.util; @@ -36,154 +36,154 @@ import com.jogamp.common.util.Ringbuffer; public abstract class RingBuffer01Base { private static boolean DEBUG = false; - + public abstract Ringbuffer createEmpty(int initialCapacity); public abstract Ringbuffer createFull(Integer[] source); - - public Integer[] createIntArray(int capacity, int startValue) { + + public Integer[] createIntArray(final int capacity, final int startValue) { final Integer[] array = new Integer[capacity]; for(int i=0; i rb, boolean clearRef, int capacity, int len, int startValue) { + + private void readTestImpl(final Ringbuffer rb, final boolean clearRef, final int capacity, final int len, final int startValue) { final int preSize = rb.size(); Assert.assertEquals("Wrong capacity "+rb, capacity, rb.capacity()); Assert.assertTrue("Too low capacity to read "+len+" elems: "+rb, capacity-len >= 0); Assert.assertTrue("Too low size to read "+len+" elems: "+rb, preSize >= len); Assert.assertTrue("Is empty "+rb, !rb.isEmpty()); - + for(int i=0; i= len); Assert.assertTrue("Is full "+rb, !rb.isFull()); } - - private void writeTestImpl(Ringbuffer rb, int capacity, int len, int startValue) { + + private void writeTestImpl(final Ringbuffer rb, final int capacity, final int len, final int startValue) { final int preSize = rb.size(); Assert.assertEquals("Wrong capacity "+rb, capacity, rb.capacity()); Assert.assertTrue("Too low capacity to write "+len+" elems: "+rb, capacity-len >= 0); Assert.assertTrue("Too low size to write "+len+" elems: "+rb, preSize+len <= capacity); Assert.assertTrue("Is full "+rb, !rb.isFull()); - + for(int i=0; i rb, int pos) { + + private void moveGetPutImpl(final Ringbuffer rb, final int pos) { Assert.assertTrue("RB is empty "+rb, !rb.isEmpty()); for(int i=0; i rb, int pos) { + + private void movePutGetImpl(final Ringbuffer rb, final int pos) { Assert.assertTrue("RB is full "+rb, !rb.isFull()); for(int i=0; i rb = createFull(source); - Assert.assertEquals("Not full size "+rb, capacity, rb.size()); + final Ringbuffer rb = createFull(source); + Assert.assertEquals("Not full size "+rb, capacity, rb.size()); Assert.assertTrue("Not full "+rb, rb.isFull()); - + readTestImpl(rb, true, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); } - + @Test public void test02_EmptyWrite() { final int capacity = 11; - final Ringbuffer rb = createEmpty(capacity); + final Ringbuffer rb = createEmpty(capacity); Assert.assertEquals("Not zero size "+rb, 0, rb.size()); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); - + writeTestImpl(rb, capacity, capacity, 0); Assert.assertEquals("Not full size "+rb, capacity, rb.size()); Assert.assertTrue("Not full "+rb, rb.isFull()); - + readTestImpl(rb, true, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); } - + @Test public void test03_FullReadReset() { final int capacity = 11; final Integer[] source = createIntArray(capacity, 0); - final Ringbuffer rb = createFull(source); + final Ringbuffer rb = createFull(source); Assert.assertTrue("Not full "+rb, rb.isFull()); - + rb.resetFull(source); Assert.assertTrue("Not full "+rb, rb.isFull()); - + readTestImpl(rb, false, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); - + rb.resetFull(source); Assert.assertTrue("Not full "+rb, rb.isFull()); - + readTestImpl(rb, false, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); } - + @Test public void test04_EmptyWriteClear() { final int capacity = 11; - final Ringbuffer rb = createEmpty(capacity); + final Ringbuffer rb = createEmpty(capacity); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); - + rb.clear(); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); - + writeTestImpl(rb, capacity, capacity, 0); Assert.assertTrue("Not full "+rb, rb.isFull()); - + readTestImpl(rb, false, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); - + rb.clear(); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); - + writeTestImpl(rb, capacity, capacity, 0); Assert.assertTrue("Not full "+rb, rb.isFull()); - + readTestImpl(rb, false, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); } - + @Test public void test05_ReadResetMid01() { final int capacity = 11; final Integer[] source = createIntArray(capacity, 0); - final Ringbuffer rb = createFull(source); + final Ringbuffer rb = createFull(source); Assert.assertTrue("Not full "+rb, rb.isFull()); - + rb.resetFull(source); Assert.assertTrue("Not full "+rb, rb.isFull()); - + readTestImpl(rb, false, capacity, 5, 0); Assert.assertTrue("Is empty "+rb, !rb.isEmpty()); Assert.assertTrue("Is Full "+rb, !rb.isFull()); - + if( DEBUG ) { rb.dump(System.err, "ReadReset01["+5+"].pre0"); } @@ -192,26 +192,26 @@ public abstract class RingBuffer01Base { if( DEBUG ) { rb.dump(System.err, "ReadReset01["+5+"].post"); } - + readTestImpl(rb, false, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); } - + @Test public void test06_ReadResetMid02() { final int capacity = 11; final Integer[] source = createIntArray(capacity, 0); - final Ringbuffer rb = createFull(source); + final Ringbuffer rb = createFull(source); Assert.assertTrue("Not full "+rb, rb.isFull()); - + rb.resetFull(source); Assert.assertTrue("Not full "+rb, rb.isFull()); - + moveGetPutImpl(rb, 5); // readTestImpl(rb, false, capacity, 5, 0); // Assert.assertTrue("Is empty "+rb, !rb.isEmpty()); // Assert.assertTrue("Is Full "+rb, !rb.isFull()); - + if( DEBUG ) { rb.dump(System.err, "ReadReset02["+5+"].pre0"); } @@ -220,12 +220,12 @@ public abstract class RingBuffer01Base { if( DEBUG ) { rb.dump(System.err, "ReadReset02["+5+"].post"); } - + readTestImpl(rb, false, capacity, capacity, 0); Assert.assertTrue("Not empty "+rb, rb.isEmpty()); } - - private void test_GrowEmptyImpl(int initCapacity, int pos) { + + private void test_GrowEmptyImpl(final int initCapacity, final int pos) { final int growAmount = 5; final int grownCapacity = initCapacity+growAmount; final Integer[] growArray = new Integer[growAmount]; @@ -233,7 +233,7 @@ public abstract class RingBuffer01Base { growArray[i] = Integer.valueOf(100+i); } final Ringbuffer rb = createEmpty(initCapacity); - + if( DEBUG ) { rb.dump(System.err, "GrowEmpty["+pos+"].pre0"); } @@ -245,18 +245,18 @@ public abstract class RingBuffer01Base { if( DEBUG ) { rb.dump(System.err, "GrowEmpty["+pos+"].post"); } - + Assert.assertEquals("Wrong capacity "+rb, grownCapacity, rb.capacity()); Assert.assertEquals("Not growAmount size "+rb, growAmount, rb.size()); Assert.assertTrue("Is full "+rb, !rb.isFull()); Assert.assertTrue("Is empty "+rb, !rb.isEmpty()); - + for(int i=0; i rb = createFull(source); - + final Ringbuffer rb = createFull(source); + if( DEBUG || debug ) { rb.dump(System.err, "GrowFull["+pos+"].pre0"); } @@ -295,29 +295,29 @@ public abstract class RingBuffer01Base { if( DEBUG || debug ) { rb.dump(System.err, "GrowFull["+pos+"].post"); } - + Assert.assertEquals("Wrong capacity "+rb, grownCapacity, rb.capacity()); Assert.assertEquals("Not orig size "+rb, initCapacity, rb.size()); Assert.assertTrue("Is full "+rb, !rb.isFull()); Assert.assertTrue("Is empty "+rb, !rb.isEmpty()); - + for(int i=0; i