it.auties.whatsapp.model.media.MediaDataSpec Maven / Gradle / Ivy
package it.auties.whatsapp.model.media;
import it.auties.whatsapp.model.media.MediaData;
import it.auties.protobuf.stream.ProtobufInputStream;
import it.auties.protobuf.stream.ProtobufOutputStream;
public class MediaDataSpec {
public static byte[] encode(MediaData protoInputObject) {
if(protoInputObject == null) {
return null;
}
var outputStream = new ProtobufOutputStream();
outputStream.writeString(1, protoInputObject.localPath());
return outputStream.toByteArray();
}
public static MediaData decode(byte[] input) {
if(input == null) {
return null;
}
var inputStream = new ProtobufInputStream(input);
java.lang.String localPath = null;
while(inputStream.readTag()) {
switch(inputStream.index()) {
case 1 -> localPath = inputStream.readString();
default -> inputStream.skipBytes();
}
}
return new it.auties.whatsapp.model.media.MediaData(localPath);
}
}