public RowLayout<Object[]> makeIntermediateLayout() { return new RowLayout<Object[]>(Kind.TUPLE, Object[].class, commonComponentClass, components); }
public boolean isPortable() { return row.isPortable(); }
@Override public String toString() { switch (kind) { case EXISTENCE: return "existence"; case ONE_VALUE: return commonComponentClass.getSimpleName(); case ARRAY: return commonComponentClass.getSimpleName() + "[]"; case TUPLE: return "TUPLE" + representComponents(); case STRUCT: return rowClass + representComponents(); case CLASS_BY_POSITIONS: return rowClass + "(positions)"; default: return "???"; } }
RowLayout(@NotNull final Kind kind, @NotNull final Class<R> rowClass, @NotNull final Class commonComponentClass, @NotNull final Class... componentClasses) { this(kind, rowClass, commonComponentClass, unnamedComponentsOf(componentClasses)); }
@Override public String toString() { switch (kind) { case EXISTENCE: return "existence"; default: return kind.name() + " of " + row.toString(); } }
public ResultLayout<List<Object[]>> makeIntermediateLayout() { return new ResultLayout<List<Object[]>>(Kind.LIST, false, row.makeIntermediateLayout()); }
@NotNull public static RowLayout<int[]> arrayOfInts() { return new RowLayout<int[]>(RowLayout.Kind.ARRAY, int[].class, int.class); }
@NotNull public static RowLayout<long[]> arrayOfLongs() { return new RowLayout<long[]>(RowLayout.Kind.ARRAY, long[].class, long.class); }
@NotNull public static RowLayout<Object[]> rawArray() { return new RowLayout<Object[]>(RowLayout.Kind.ARRAY, Object[].class, Object.class); }
@NotNull public static <V> RowLayout<V> oneOf(@NotNull final Class<V> valueClass) { return new RowLayout<V>(RowLayout.Kind.ONE_VALUE, valueClass, valueClass, valueClass); }
@NotNull public static RowLayout<Object[]> arrayOf(@NotNull final Class... componentClasses) { return new RowLayout<Object[]>(RowLayout.Kind.ARRAY, Object[].class, Object.class, componentClasses); }
@SuppressWarnings("unchecked") @NotNull public static <V> RowLayout<V[]> arrayOf(int n, @NotNull final Class<V> componentClass) { V[] example = (V[]) Array.newInstance(componentClass,0); Class resultClass = example.getClass(); Class<V>[] componentClasses = (Class<V>[]) new Class[n]; for (int i = 0; i < n; i++) componentClasses[i] = componentClass; return new RowLayout<V[]>(RowLayout.Kind.ARRAY, resultClass, componentClass, componentClasses); }
@NotNull public static <C> RowLayout<C> structOf(@NotNull final Class<C> structClass) { final NameAndClass[] assignableFields = Classes.assignableFieldsOf(structClass); return new RowLayout<C>(RowLayout.Kind.STRUCT, structClass, Object.class, assignableFields); }