Skip to content
Snippets Groups Projects
Unverified Commit 15778000 authored by Philipp Hanslovsky's avatar Philipp Hanslovsky
Browse files

Do not cache next interpolation as member

This ensures that next works even when new interpolations are added.

Also test it
parent c9e036b3
Branches
Tags
No related merge requests found
......@@ -193,5 +193,11 @@
<artifactId>scijava-listeners</artifactId>
<version>1.0.0-beta-2</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
......@@ -37,15 +37,8 @@ public enum Interpolation
NEARESTNEIGHBOR( "nearest-neighbor interpolation" ),
NLINEAR( "tri-linear interpolation" );
static {
NEARESTNEIGHBOR.next = NLINEAR;
NLINEAR.next = NEARESTNEIGHBOR;
}
private final String name;
private Interpolation next = null;
private Interpolation( final String name )
{
this.name = name;
......@@ -57,6 +50,6 @@ public enum Interpolation
}
public Interpolation next() {
return next;
return Interpolation.values()[ ( this.ordinal() + 1 ) % Interpolation.values().length ];
}
}
package bdv.viewer;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
public class InterpolationTest {
@Test
public void next() {
Assert.assertEquals( Interpolation.NLINEAR, Interpolation.NEARESTNEIGHBOR.next() );
Assert.assertEquals( Interpolation.NEARESTNEIGHBOR, Interpolation.NLINEAR.next() );
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment