All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.proximax.sdk.model.transaction.MessageFactory Maven / Gradle / Ivy

Go to download

The ProximaX Sirius Chain Java SDK is a Java library for interacting with the Sirius Blockchain.

The newest version!
package io.proximax.sdk.model.transaction;

import java.nio.charset.StandardCharsets;

/**
 * The factory to create Message instance.
 */
public class MessageFactory {

   /* hiding constructor for utility class */
   private MessageFactory() { /* nothing o do here */ }
    /**
     * Create Message instance based on type and encodedPayload
     * @param type the message type
     * @param encodedPayload the encodedPayload in byte array
     * @return the instance of Message
     */
    public static Message createMessage(int type, byte[] encodedPayload) {
        if (type == MessageType.PLAIN.getCode()) {
            return PlainMessage.create(new String(encodedPayload, StandardCharsets.UTF_8));
        } else if (type == MessageType.SECURE.getCode()){
            return SecureMessage.createFromEncodedPayload(encodedPayload);
        }
        return PlainMessage.EMPTY;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy