summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/util/LFRingbuffer.java
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-07-03 16:06:47 +0200
committerSven Gothel <[email protected]>2014-07-03 16:06:47 +0200
commitdf9ff7f340a5ab4e07efc613f5f264eeae63d4c7 (patch)
tree239ae276b82024b140428e6c0fe5d739fdd686a4 /src/java/com/jogamp/common/util/LFRingbuffer.java
parenteb47aaba63e3b1bf55f274a0f338f1010a017ae4 (diff)
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
Diffstat (limited to 'src/java/com/jogamp/common/util/LFRingbuffer.java')
-rw-r--r--src/java/com/jogamp/common/util/LFRingbuffer.java36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/java/com/jogamp/common/util/LFRingbuffer.java b/src/java/com/jogamp/common/util/LFRingbuffer.java
index a0418c5..685c529 100644
--- a/src/java/com/jogamp/common/util/LFRingbuffer.java
+++ b/src/java/com/jogamp/common/util/LFRingbuffer.java
@@ -87,7 +87,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
}
@Override
- public final void dump(PrintStream stream, String prefix) {
+ public final void dump(final PrintStream stream, final String prefix) {
stream.println(prefix+" "+toString()+" {");
for(int i=0; i<capacityPlusOne; i++) {
stream.println("\t["+i+"]: "+array[i]);
@@ -116,7 +116,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
* @throws IllegalArgumentException if <code>copyFrom</code> is <code>null</code>
*/
@SuppressWarnings("unchecked")
- public LFRingbuffer(T[] copyFrom) throws IllegalArgumentException {
+ public LFRingbuffer(final T[] copyFrom) throws IllegalArgumentException {
capacityPlusOne = copyFrom.length + 1;
array = (T[]) newArray(copyFrom.getClass(), capacityPlusOne);
resetImpl(true, copyFrom);
@@ -139,9 +139,9 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
* @param arrayType the array type of the created empty internal array.
* @param capacity the initial net capacity of the ring buffer
*/
- public LFRingbuffer(Class<? extends T[]> arrayType, int capacity) {
+ public LFRingbuffer(final Class<? extends T[]> arrayType, final int capacity) {
capacityPlusOne = capacity+1;
- array = (T[]) newArray(arrayType, capacityPlusOne);
+ array = newArray(arrayType, capacityPlusOne);
resetImpl(false, null /* empty, nothing to copy */ );
}
@@ -162,11 +162,11 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
}
@Override
- public final void resetFull(T[] copyFrom) throws IllegalArgumentException {
+ public final void resetFull(final T[] copyFrom) throws IllegalArgumentException {
resetImpl(true, copyFrom);
}
- private final void resetImpl(boolean full, T[] copyFrom) throws IllegalArgumentException {
+ private final void resetImpl(final boolean full, final T[] copyFrom) throws IllegalArgumentException {
synchronized ( syncGlobal ) {
if( null != copyFrom ) {
if( copyFrom.length != capacityPlusOne-1 ) {
@@ -210,7 +210,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
public final T get() {
try {
return getImpl(false, false);
- } catch (InterruptedException ie) { throw new RuntimeException(ie); }
+ } catch (final InterruptedException ie) { throw new RuntimeException(ie); }
}
/**
@@ -228,14 +228,14 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
public final T peek() {
try {
return getImpl(false, true);
- } catch (InterruptedException ie) { throw new RuntimeException(ie); }
+ } catch (final InterruptedException ie) { throw new RuntimeException(ie); }
}
@Override
public final T peekBlocking() throws InterruptedException {
return getImpl(true, true);
}
- private final T getImpl(boolean blocking, boolean peek) throws InterruptedException {
+ private final T getImpl(final boolean blocking, final boolean peek) throws InterruptedException {
int localReadPos = readPos;
if( localReadPos == writePos ) {
if( blocking ) {
@@ -268,10 +268,10 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
* </p>
*/
@Override
- public final boolean put(T e) {
+ public final boolean put(final T e) {
try {
return putImpl(e, false, false);
- } catch (InterruptedException ie) { throw new RuntimeException(ie); }
+ } catch (final InterruptedException ie) { throw new RuntimeException(ie); }
}
/**
@@ -281,7 +281,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
* </p>
*/
@Override
- public final void putBlocking(T e) throws InterruptedException {
+ public final void putBlocking(final T e) throws InterruptedException {
if( !putImpl(e, false, true) ) {
throw new InternalError("Blocking put failed: "+this);
}
@@ -294,11 +294,11 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
* </p>
*/
@Override
- public final boolean putSame(boolean blocking) throws InterruptedException {
+ public final boolean putSame(final boolean blocking) throws InterruptedException {
return putImpl(null, true, blocking);
}
- private final boolean putImpl(T e, boolean sameRef, boolean blocking) throws InterruptedException {
+ private final boolean putImpl(final T e, final boolean sameRef, final boolean blocking) throws InterruptedException {
int localWritePos = writePos;
localWritePos = (localWritePos + 1) % capacityPlusOne;
if( localWritePos == readPos ) {
@@ -325,7 +325,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
@Override
- public final void waitForFreeSlots(int count) throws InterruptedException {
+ public final void waitForFreeSlots(final int count) throws InterruptedException {
synchronized ( syncRead ) {
if( capacityPlusOne - 1 - size < count ) {
while( capacityPlusOne - 1 - size < count ) {
@@ -361,7 +361,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
final int growAmount = newElements.length;
final int newCapacity = capacityPlusOne + growAmount;
final T[] oldArray = array;
- final T[] newArray = (T[]) newArray(arrayTypeInternal, newCapacity);
+ final T[] newArray = newArray(arrayTypeInternal, newCapacity);
// writePos == readPos
writePos += growAmount; // warp writePos to the end of the new data location
@@ -401,7 +401,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
final int newCapacity = capacityPlusOne + growAmount;
final T[] oldArray = array;
- final T[] newArray = (T[]) newArray(arrayTypeInternal, newCapacity);
+ final T[] newArray = newArray(arrayTypeInternal, newCapacity);
// writePos == readPos - 1
readPos = ( writePos + 1 + growAmount ) % newCapacity; // warp readPos to the end of the new data location
@@ -420,7 +420,7 @@ public class LFRingbuffer<T> implements Ringbuffer<T> {
}
@SuppressWarnings("unchecked")
- private static <T> T[] newArray(Class<? extends T[]> arrayType, int length) {
+ private static <T> T[] newArray(final Class<? extends T[]> arrayType, final int length) {
return ((Object)arrayType == (Object)Object[].class)
? (T[]) new Object[length]
: (T[]) Array.newInstance(arrayType.getComponentType(), length);