Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -358,68 +358,103 @@ public void setBooleanArray(T bytes, int index, boolean[] values) {
}

@Override
public void setBooleanArray(T bytes, int index, Boolean[] values) {
delegate.setBooleanArray(bytes, index, values);
public void setByteArray(T bytes, int index, byte[] values) {
delegate.setByteArray(bytes, index, values);
}

@Override
public void setByteArray(T bytes, int index, byte[] values) {
delegate.setByteArray(bytes, index, values);
public void setShortArray(T bytes, int index, short[] values) {
delegate.setShortArray(bytes, index, values);
}

@Override
public void setByteArray(T bytes, int index, Byte[] values) {
delegate.setByteArray(bytes, index, values);
public void setIntArray(T bytes, int index, int[] values) {
delegate.setIntArray(bytes, index, values);
}

@Override
public void setShortArray(T bytes, int index, short[] values) {
delegate.setShortArray(bytes, index, values);
public void setLongArray(T bytes, int index, long[] values) {
delegate.setLongArray(bytes, index, values);
}

@Override
public void setShortArray(T bytes, int index, Short[] values) {
delegate.setShortArray(bytes, index, values);
public void setFloatArray(T bytes, int index, float[] values) {
delegate.setFloatArray(bytes, index, values);
}

@Override
public void setIntArray(T bytes, int index, int[] values) {
delegate.setIntArray(bytes, index, values);
public void setDoubleArray(T bytes, int index, double[] values) {
delegate.setDoubleArray(bytes, index, values);
}

@Override
public void setIntArray(T bytes, int index, Integer[] values) {
delegate.setIntArray(bytes, index, values);
public Boolean[] getBoxedBooleanArray(T bytes, int index, int length) {
return delegate.getBoxedBooleanArray(bytes, index, length);
}

@Override
public void setLongArray(T bytes, int index, long[] values) {
delegate.setLongArray(bytes, index, values);
public void setBoxedBooleanArray(T bytes, int index, Boolean[] values) {
delegate.setBoxedBooleanArray(bytes, index, values);
}

@Override
public void setLongArray(T bytes, int index, Long[] values) {
delegate.setLongArray(bytes, index, values);
public Byte[] getBoxedByteArray(T bytes, int index, int length) {
return delegate.getBoxedByteArray(bytes, index, length);
}

@Override
public void setFloatArray(T bytes, int index, float[] values) {
delegate.setFloatArray(bytes, index, values);
public void setBoxedByteArray(T bytes, int index, Byte[] values) {
delegate.setBoxedByteArray(bytes, index, values);
}

@Override
public void setFloatArray(T bytes, int index, Float[] values) {
delegate.setFloatArray(bytes, index, values);
public Short[] getBoxedShortArray(T bytes, int index, int length) {
return delegate.getBoxedShortArray(bytes, index, length);
}

@Override
public void setDoubleArray(T bytes, int index, double[] values) {
delegate.setDoubleArray(bytes, index, values);
public void setBoxedShortArray(T bytes, int index, Short[] values) {
delegate.setBoxedShortArray(bytes, index, values);
}

@Override
public void setDoubleArray(T bytes, int index, Double[] values) {
delegate.setDoubleArray(bytes, index, values);
public Integer[] getBoxedIntArray(T bytes, int index, int length) {
return delegate.getBoxedIntArray(bytes, index, length);
}

@Override
public void setBoxedIntArray(T bytes, int index, Integer[] values) {
delegate.setBoxedIntArray(bytes, index, values);
}

@Override
public Long[] getBoxedLongArray(T bytes, int index, int length) {
return delegate.getBoxedLongArray(bytes, index, length);
}

@Override
public void setBoxedLongArray(T bytes, int index, Long[] values) {
delegate.setBoxedLongArray(bytes, index, values);
}

@Override
public Float[] getBoxedFloatArray(T bytes, int index, int length) {
return delegate.getBoxedFloatArray(bytes, index, length);
}

@Override
public void setBoxedFloatArray(T bytes, int index, Float[] values) {
delegate.setBoxedFloatArray(bytes, index, values);
}

@Override
public Double[] getBoxedDoubleArray(T bytes, int index, int length) {
return delegate.getBoxedDoubleArray(bytes, index, length);
}

@Override
public void setBoxedDoubleArray(T bytes, int index, Double[] values) {
delegate.setBoxedDoubleArray(bytes, index, values);
}

// endregion
Expand Down
131 changes: 106 additions & 25 deletions byteops/src/main/java/com/digitalpetri/util/AbstractByteOps.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,93 +185,174 @@ public void setBooleanArray(T bytes, int index, boolean[] values) {
}

@Override
public void setBooleanArray(T bytes, int index, Boolean[] values) {
public void setByteArray(T bytes, int index, byte[] values) {
for (int i = 0; i < values.length; i++) {
setBoolean(bytes, index + i, values[i]);
setByte(bytes, index + i, values[i]);
}
}

@Override
public void setByteArray(T bytes, int index, byte[] values) {
public void setShortArray(T bytes, int index, short[] values) {
for (int i = 0; i < values.length; i++) {
setByte(bytes, index + i, values[i]);
setShort(bytes, index + i * 2, values[i]);
}
}

@Override
public void setByteArray(T bytes, int index, Byte[] values) {
public void setIntArray(T bytes, int index, int[] values) {
for (int i = 0; i < values.length; i++) {
setByte(bytes, index + i, values[i]);
setInt(bytes, index + i * 4, values[i]);
}
}

@Override
public void setShortArray(T bytes, int index, short[] values) {
public void setLongArray(T bytes, int index, long[] values) {
for (int i = 0; i < values.length; i++) {
setShort(bytes, index + i * 2, values[i]);
setLong(bytes, index + i * 8, values[i]);
}
}

@Override
public void setShortArray(T bytes, int index, Short[] values) {
public void setFloatArray(T bytes, int index, float[] values) {
for (int i = 0; i < values.length; i++) {
setShort(bytes, index + i * 2, values[i]);
setFloat(bytes, index + i * 4, values[i]);
}
}

@Override
public void setIntArray(T bytes, int index, int[] values) {
public void setDoubleArray(T bytes, int index, double[] values) {
for (int i = 0; i < values.length; i++) {
setInt(bytes, index + i * 4, values[i]);
setDouble(bytes, index + i * 8, values[i]);
}
}

// region Boxed Array Support

@Override
public void setIntArray(T bytes, int index, Integer[] values) {
public Boolean[] getBoxedBooleanArray(T bytes, int index, int length) {
var value = new Boolean[length];

for (int i = 0; i < length; i++) {
value[i] = getBoolean(bytes, index + i);
}

return value;
}

@Override
public Byte[] getBoxedByteArray(T bytes, int index, int length) {
var value = new Byte[length];

for (int i = 0; i < length; i++) {
value[i] = getByte(bytes, index + i);
}

return value;
}

@Override
public Short[] getBoxedShortArray(T bytes, int index, int length) {
var value = new Short[length];

for (int i = 0; i < length; i++) {
value[i] = getShort(bytes, index + i * 2);
}

return value;
}

@Override
public Integer[] getBoxedIntArray(T bytes, int index, int length) {
var value = new Integer[length];

for (int i = 0; i < length; i++) {
value[i] = getInt(bytes, index + i * 4);
}

return value;
}

@Override
public Long[] getBoxedLongArray(T bytes, int index, int length) {
var value = new Long[length];

for (int i = 0; i < length; i++) {
value[i] = getLong(bytes, index + i * 8);
}

return value;
}

@Override
public Float[] getBoxedFloatArray(T bytes, int index, int length) {
var value = new Float[length];

for (int i = 0; i < length; i++) {
value[i] = getFloat(bytes, index + i * 4);
}

return value;
}

@Override
public Double[] getBoxedDoubleArray(T bytes, int index, int length) {
var value = new Double[length];

for (int i = 0; i < length; i++) {
value[i] = getDouble(bytes, index + i * 8);
}

return value;
}

@Override
public void setBoxedBooleanArray(T bytes, int index, Boolean[] values) {
for (int i = 0; i < values.length; i++) {
setInt(bytes, index + i * 4, values[i]);
setBoolean(bytes, index + i, values[i]);
}
}

@Override
public void setLongArray(T bytes, int index, long[] values) {
public void setBoxedByteArray(T bytes, int index, Byte[] values) {
for (int i = 0; i < values.length; i++) {
setLong(bytes, index + i * 8, values[i]);
setByte(bytes, index + i, values[i]);
}
}

@Override
public void setLongArray(T bytes, int index, Long[] values) {
public void setBoxedShortArray(T bytes, int index, Short[] values) {
for (int i = 0; i < values.length; i++) {
setLong(bytes, index + i * 8, values[i]);
setShort(bytes, index + i * 2, values[i]);
}
}

@Override
public void setFloatArray(T bytes, int index, float[] values) {
public void setBoxedIntArray(T bytes, int index, Integer[] values) {
for (int i = 0; i < values.length; i++) {
setFloat(bytes, index + i * 4, values[i]);
setInt(bytes, index + i * 4, values[i]);
}
}

@Override
public void setFloatArray(T bytes, int index, Float[] values) {
public void setBoxedLongArray(T bytes, int index, Long[] values) {
for (int i = 0; i < values.length; i++) {
setFloat(bytes, index + i * 4, values[i]);
setLong(bytes, index + i * 8, values[i]);
}
}

@Override
public void setDoubleArray(T bytes, int index, double[] values) {
public void setBoxedFloatArray(T bytes, int index, Float[] values) {
for (int i = 0; i < values.length; i++) {
setDouble(bytes, index + i * 8, values[i]);
setFloat(bytes, index + i * 4, values[i]);
}
}

@Override
public void setDoubleArray(T bytes, int index, Double[] values) {
public void setBoxedDoubleArray(T bytes, int index, Double[] values) {
for (int i = 0; i < values.length; i++) {
setDouble(bytes, index + i * 8, values[i]);
}
}

// endregion
}
Loading