Streamers { public static <S extends AnnotatedSpace<A>, A extends TypedAxis> Stream<A> spatialAxisStream(final S space) { return axisStream(space).filter(a -> a.type().isSpatial()); } private  Streamers(); static Stream<A> axisStream(final S space); static Stream<A> spatialAxisStream(final S space);  }
@Test public void testSpatialAxisStream() { final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X); final DefaultLinearAxis tAxis = new DefaultLinearAxis(Axes.TIME); final DefaultLinearAxis yAxis = new DefaultLinearAxis(Axes.Y); final long[] dimensions = { 10, 3, 10 }; final Img<DoubleType> img = ArrayImgs.doubles(dimensions); final ImgPlus<DoubleType> imgPlus = new ImgPlus<>(img, "Test image", xAxis, tAxis, yAxis); final List<AxisType> result = Streamers.spatialAxisStream(imgPlus).map( TypedAxis::type).collect(Collectors.toList()); assertNotNull("Stream should not be null", result); assertEquals("Wrong number of axes in stream", 2, result.size()); assertEquals("Axes in the stream are in wrong order", Axes.X, result.get( 0)); assertEquals("Axes in the stream are in wrong order", Axes.Y, result.get( 1)); }