Skip to content
Merged
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
Make uPayload static methods public
The newly added pack and unbpack messages were not public so people using up-java was not able to call them.

#149
  • Loading branch information
czfdcn committed Jul 12, 2024
commit f5db8ec6756fa256196f901c7e3d22fd24881539
10 changes: 5 additions & 5 deletions src/main/java/org/eclipse/uprotocol/communication/UPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static boolean isEmpty(UPayload payload) {
* @param message the message to pack
* @return the UPayload
*/
static UPayload packToAny(Message message) {
public static UPayload packToAny(Message message) {
return message == null ? UPayload.EMPTY :
new UPayload(Any.pack(message).toByteString(), UPayloadFormat.UPAYLOAD_FORMAT_PROTOBUF_WRAPPED_IN_ANY);
}
Expand All @@ -70,7 +70,7 @@ static UPayload packToAny(Message message) {
* @param message the message to pack
* @return the UPayload
*/
static UPayload pack(Message message) {
public static UPayload pack(Message message) {
return message == null ? UPayload.EMPTY :
new UPayload(message.toByteString(), UPayloadFormat.UPAYLOAD_FORMAT_PROTOBUF);
}
Expand All @@ -81,7 +81,7 @@ static UPayload pack(Message message) {
* @param format payload format.
* @return the UPayload.
*/
static UPayload pack(ByteString data, UPayloadFormat format) {
public static UPayload pack(ByteString data, UPayloadFormat format) {
return new UPayload(data, format);
}

Expand All @@ -95,7 +95,7 @@ static UPayload pack(ByteString data, UPayloadFormat format) {
* @param clazz the class of the message to unpack
* @return the unpacked message
*/
static <T extends Message> Optional<T> unpack(UPayload payload, Class<T> clazz) {
public static <T extends Message> Optional<T> unpack(UPayload payload, Class<T> clazz) {
if (payload == null) {
return Optional.empty();
}
Expand All @@ -114,7 +114,7 @@ static <T extends Message> Optional<T> unpack(UPayload payload, Class<T> clazz)
* @return the unpacked message
*/
@SuppressWarnings("unchecked")
static <T extends Message> Optional<T> unpack(ByteString data, UPayloadFormat format, Class<T> clazz) {
public static <T extends Message> Optional<T> unpack(ByteString data, UPayloadFormat format, Class<T> clazz) {
format = Objects.requireNonNullElse(format, UPayloadFormat.UPAYLOAD_FORMAT_UNSPECIFIED);
if (data == null || data.isEmpty()) {
return Optional.empty();
Expand Down