void (final DataOutput out) { super.save(out); myType.save(out); try { final Object val = myValue; final Class valueType = val != null? val.getClass() : null; if (valueType != null && valueType.isArray()) { final int length = Array.getLength(val); final Class dataType = length > 0? Array.get(val, 0).getClass() : valueType.getComponentType(); final DataDescriptor descriptor = DataDescriptor.findByValueType(dataType); out.writeByte(-descriptor.getId()); if (descriptor != DataDescriptor.NONE) { DataInputOutputUtil.writeINT(out, length); for (int idx = 0; idx < length; idx++) { final Object element = Array.get(val, idx); //noinspection unchecked descriptor.save(out, element); } } } else { final DataDescriptor descriptor = DataDescriptor.findByValueType(valueType); out.writeByte(descriptor.getId()); //noinspection unchecked descriptor.save(out, val); } } catch (IOException e) { throw new BuildDataCorruptedException(e); } catch (Exception e) { throw new RuntimeException(e); } }