class ArraysConvert {

  public static ucar.ma2.Array convertFromArray(Array<?> from) {
    // Look this is not handling Structures, Opaques, Vlens correctly
    Preconditions.checkArgument(!(from instanceof ArrayVlen), "Cant convert Vlen");
    Preconditions.checkArgument(from.dataType != DataType.OPAQUE, "Cant convert Opaque");
    Preconditions.checkArgument(from.dataType != DataType.SEQUENCE, "Cant convert Sequence");

    if (from.dataType == DataType.STRUCTURE) {
      return convertStructureDataArray(from);
    }

    ucar.ma2.Array values = ucar.ma2.Array.factory(from.getDataType(), from.getShape());
    int count = 0;
    for (Object val : from) {
      values.setObject(count++, val);
    }
    return values;
  }

}