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
2 changes: 1 addition & 1 deletion .github/workflows/maven-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
server-id: ossrh
server-username: MAVEN_USERNAME
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
server-id: ossrh
server-username: MAVEN_USERNAME
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '11'
java-version: '17'
distribution: 'temurin'
cache: maven

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,21 @@

public final class ByteBufByteOps extends AbstractByteOps<ByteBuf> {

/**
* {@link ByteBufByteOps} that assumes big-endian byte order.
*/
public static final ByteBufByteOps BIG_ENDIAN =
new ByteBufByteOps(new OrderedOps.BigEndianOps());

/**
* {@link ByteBufByteOps} that assumes little-endian byte order.
*/
/** {@link ByteBufByteOps} that assumes big-endian byte order. */
public static final ByteBufByteOps BIG_ENDIAN = new ByteBufByteOps(new OrderedOps.BigEndianOps());

/** {@link ByteBufByteOps} that assumes little-endian byte order. */
public static final ByteBufByteOps LITTLE_ENDIAN =
new ByteBufByteOps(new OrderedOps.LittleEndianOps());

/**
* {@link ByteBufByteOps} that assumes big-endian byte order and low-high word order.
*/
/** {@link ByteBufByteOps} that assumes big-endian byte order and low-high word order. */
public static final ByteBufByteOps BIG_ENDIAN_LOW_HIGH =
new ByteBufByteOps(new OrderedOps.BigEndianLowHighOps());

/**
* {@link ByteBufByteOps} that assumes little-endian byte order and low-high word order.
*/
/** {@link ByteBufByteOps} that assumes little-endian byte order and low-high word order. */
public static final ByteBufByteOps LITTLE_ENDIAN_LOW_HIGH =
new ByteBufByteOps(new OrderedOps.LittleEndianLowHighOps());


public ByteBufByteOps(OrderedOps orderedOps) {
super(orderedOps);
}
Expand All @@ -42,5 +32,4 @@ protected byte get(ByteBuf bytes, int index) {
protected void set(ByteBuf bytes, int index, byte value) {
bytes.setByte(index, value);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ protected ByteOps<ByteBuf> getSwappedByteOps(ByteOrder byteOrder) {
throw new IllegalArgumentException("unsupported byte order: " + byteOrder);
}
}

}
22 changes: 5 additions & 17 deletions byteops/src/main/java/com/digitalpetri/util/ByteArrayByteOps.java
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
package com.digitalpetri.util;

/**
* {@link ByteOps} implementation that operates on byte arrays.
*/
/** {@link ByteOps} implementation that operates on byte arrays. */
public final class ByteArrayByteOps extends AbstractByteOps<byte[]> {

/**
* {@link ByteArrayByteOps} that assumes big-endian byte order.
*/
/** {@link ByteArrayByteOps} that assumes big-endian byte order. */
public static final ByteArrayByteOps BIG_ENDIAN =
new ByteArrayByteOps(new OrderedOps.BigEndianOps());

/**
* {@link ByteArrayByteOps} that assumes little-endian byte order.
*/
/** {@link ByteArrayByteOps} that assumes little-endian byte order. */
public static final ByteArrayByteOps LITTLE_ENDIAN =
new ByteArrayByteOps(new OrderedOps.LittleEndianOps());

/**
* {@link ByteArrayByteOps} that assumes big-endian byte order and low-high word order.
*/
/** {@link ByteArrayByteOps} that assumes big-endian byte order and low-high word order. */
public static final ByteArrayByteOps BIG_ENDIAN_LOW_HIGH =
new ByteArrayByteOps(new OrderedOps.BigEndianLowHighOps());

/**
* {@link ByteArrayByteOps} that assumes little-endian byte order and low-high word order.
*/
/** {@link ByteArrayByteOps} that assumes little-endian byte order and low-high word order. */
public static final ByteArrayByteOps LITTLE_ENDIAN_LOW_HIGH =
new ByteArrayByteOps(new OrderedOps.LittleEndianLowHighOps());


public ByteArrayByteOps(OrderedOps orderedOps) {
super(orderedOps);
}
Expand All @@ -43,5 +32,4 @@ protected byte get(byte[] bytes, int index) {
protected void set(byte[] bytes, int index, byte value) {
bytes[index] = value;
}

}
22 changes: 5 additions & 17 deletions byteops/src/main/java/com/digitalpetri/util/ByteBufferByteOps.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,25 @@

import java.nio.ByteBuffer;

/**
* {@link ByteOps} implementation that operates on {@link ByteBuffer}s.
*/
/** {@link ByteOps} implementation that operates on {@link ByteBuffer}s. */
public final class ByteBufferByteOps extends AbstractByteOps<ByteBuffer> {

/**
* {@link ByteBufferByteOps} that assumes big-endian byte order.
*/
/** {@link ByteBufferByteOps} that assumes big-endian byte order. */
public static final ByteBufferByteOps BIG_ENDIAN =
new ByteBufferByteOps(new OrderedOps.BigEndianOps());

/**
* {@link ByteBufferByteOps} that assumes little-endian byte order.
*/
/** {@link ByteBufferByteOps} that assumes little-endian byte order. */
public static final ByteBufferByteOps LITTLE_ENDIAN =
new ByteBufferByteOps(new OrderedOps.LittleEndianOps());

/**
* {@link ByteBufferByteOps} that assumes big-endian byte order and low-high word order.
*/
/** {@link ByteBufferByteOps} that assumes big-endian byte order and low-high word order. */
public static final ByteBufferByteOps BIG_ENDIAN_LOW_HIGH =
new ByteBufferByteOps(new OrderedOps.BigEndianLowHighOps());

/**
* {@link ByteBufferByteOps} that assumes little-endian byte order and low-high word order.
*/
/** {@link ByteBufferByteOps} that assumes little-endian byte order and low-high word order. */
public static final ByteBufferByteOps LITTLE_ENDIAN_LOW_HIGH =
new ByteBufferByteOps(new OrderedOps.LittleEndianLowHighOps());


public ByteBufferByteOps(OrderedOps orderedOps) {
super(orderedOps);
}
Expand All @@ -45,5 +34,4 @@ protected byte get(ByteBuffer bytes, int index) {
protected void set(ByteBuffer bytes, int index, byte value) {
bytes.put(index, value);
}

}
57 changes: 38 additions & 19 deletions byteops/src/main/java/com/digitalpetri/util/OrderedOps.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ public interface OrderedOps {
long getLong(Function<Integer, Byte> getByte, int index);

/**
* Set the bytes of a short value using the given {@code setByte} function, starting
* {@code index}.
* Set the bytes of a short value using the given {@code setByte} function, starting {@code
* index}.
*
* @param setByte a function that takes an index and a byte value to set.
* @param index the index to start at.
Expand All @@ -47,8 +47,8 @@ public interface OrderedOps {
void setShort(BiConsumer<Integer, Byte> setByte, int index, short value);

/**
* Set the bytes of an int value using the given {@code setByte} function, starting at
* {@code index}.
* Set the bytes of an int value using the given {@code setByte} function, starting at {@code
* index}.
*
* @param setByte a function that takes an index and a byte value to set.
* @param index the index to start at.
Expand All @@ -57,8 +57,8 @@ public interface OrderedOps {
void setInt(BiConsumer<Integer, Byte> setByte, int index, int value);

/**
* Set the bytes of a long value using the given {@code setByte} function, starting at
* {@code index}.
* Set the bytes of a long value using the given {@code setByte} function, starting at {@code
* index}.
*
* @param setByte a function that takes an index and a byte value to set.
* @param index the index to start at.
Expand Down Expand Up @@ -103,8 +103,14 @@ public long getLong(Function<Integer, Byte> getByte, int index) {
long b5 = getByte.apply(index + 5) & 0xFF;
long b6 = getByte.apply(index + 6) & 0xFF;
long b7 = getByte.apply(index + 7) & 0xFF;
return (b0 << 56) | (b1 << 48) | (b2 << 40) | (b3 << 32)
| (b4 << 24) | (b5 << 16) | (b6 << 8) | b7;
return (b0 << 56)
| (b1 << 48)
| (b2 << 40)
| (b3 << 32)
| (b4 << 24)
| (b5 << 16)
| (b6 << 8)
| b7;
}

@Override
Expand Down Expand Up @@ -132,7 +138,6 @@ public void setLong(BiConsumer<Integer, Byte> setByte, int index, long value) {
setByte.accept(index + 6, (byte) (value >> 8 & 0xFF));
setByte.accept(index + 7, (byte) (value & 0xFF));
}

}

/**
Expand Down Expand Up @@ -172,8 +177,14 @@ public long getLong(Function<Integer, Byte> getByte, int index) {
long b5 = getByte.apply(index + 5) & 0xFF;
long b6 = getByte.apply(index + 6) & 0xFF;
long b7 = getByte.apply(index + 7) & 0xFF;
return (b7 << 56) | (b6 << 48) | (b5 << 40) | (b4 << 32)
| (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
return (b7 << 56)
| (b6 << 48)
| (b5 << 40)
| (b4 << 32)
| (b3 << 24)
| (b2 << 16)
| (b1 << 8)
| b0;
}

@Override
Expand Down Expand Up @@ -201,7 +212,6 @@ public void setLong(BiConsumer<Integer, Byte> setByte, int index, long value) {
setByte.accept(index + 6, (byte) (value >> 48 & 0xFF));
setByte.accept(index + 7, (byte) (value >> 56 & 0xFF));
}

}

/**
Expand Down Expand Up @@ -241,8 +251,14 @@ public long getLong(Function<Integer, Byte> getByte, int index) {
long b5 = getByte.apply(index + 5) & 0xFF;
long b6 = getByte.apply(index + 6) & 0xFF;
long b7 = getByte.apply(index + 7) & 0xFF;
return (b6 << 56) | (b7 << 48) | (b4 << 40) | (b5 << 32)
| (b2 << 24) | (b3 << 16) | (b0 << 8) | b1;
return (b6 << 56)
| (b7 << 48)
| (b4 << 40)
| (b5 << 32)
| (b2 << 24)
| (b3 << 16)
| (b0 << 8)
| b1;
}

@Override
Expand Down Expand Up @@ -270,7 +286,6 @@ public void setLong(BiConsumer<Integer, Byte> setByte, int index, long value) {
setByte.accept(index + 6, (byte) (value >> 56 & 0xFF));
setByte.accept(index + 7, (byte) (value >> 48 & 0xFF));
}

}

/**
Expand Down Expand Up @@ -310,8 +325,14 @@ public long getLong(Function<Integer, Byte> getByte, int index) {
long b5 = getByte.apply(index + 5) & 0xFF;
long b6 = getByte.apply(index + 6) & 0xFF;
long b7 = getByte.apply(index + 7) & 0xFF;
return (b1 << 56) | (b0 << 48) | (b3 << 40) | (b2 << 32)
| (b5 << 24) | (b4 << 16) | (b7 << 8) | b6;
return (b1 << 56)
| (b0 << 48)
| (b3 << 40)
| (b2 << 32)
| (b5 << 24)
| (b4 << 16)
| (b7 << 8)
| b6;
}

@Override
Expand Down Expand Up @@ -339,7 +360,5 @@ public void setLong(BiConsumer<Integer, Byte> setByte, int index, long value) {
setByte.accept(index + 6, (byte) (value & 0xFF));
setByte.accept(index + 7, (byte) (value >> 8 & 0xFF));
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@ protected ByteOps<byte[]> getSwappedByteOps(ByteOrder byteOrder) {
throw new IllegalArgumentException("unsupported byte order: " + byteOrder);
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ protected ByteOps<ByteBuffer> getSwappedByteOps(ByteOrder byteOrder) {
throw new IllegalArgumentException("unsupported byte order: " + byteOrder);
}
}

}
Loading