Stoa library provides Structure of Arrays in Java, compatible with the standard Collection interfaces.
StoaBuilder provides static methods which return Supplier to construct a list, map or set. For example StoaBuilder.list(BeanInfo info) yields a List<> compatible object that maps the Bean fields onto arrays. Similarly for map() and set().
public class Point2D {
private int x;
private int y;
private boolean insideVolume;
// getter, setters and constructors here ...
};
public static void main(String args[]) throws IntrospectionException {
Stoa<Point2D> points = StoaBuilder.<Point2D>list(Introspector.getBeanInfo(Point2D.class, Object.class)).get();
points.add(new Point2D(1, 1, false));
points.add(new Point2D(2, 3, true));
points.add(new Point2D(5, 7, false));
points.add(new Point2D(11, 13, true));
System.out.println(Arrays.toString((int[]) points.data("x")));
System.out.println(Arrays.toString((int[]) points.data("y")));
System.out.println(Arrays.toString((long[]) points.data("insideVolume"))); // Note that booleans are stored inside a long array
}
$ mvn package
GNU LGPL v3. Please see LICENSE file for details.