class MqttMessageRequest {

    private String topic;

    private int qosLevel;

    private Object data;

    private int messageId;

    private boolean will;

    private boolean dup;

    private boolean retain;

    public static MqttMessage of(MqttMessageRequest request, PayloadType type) {<FILL_FUNCTION_BODY>}

    public static MqttMessageRequest of(MqttMessage message, PayloadType type) {
        MqttMessageRequest requestMessage = new MqttMessageRequest();
        requestMessage.setTopic(message.getTopic());
        requestMessage.setQosLevel(message.getQosLevel());
        requestMessage.setData(type.read(message.getPayload()));
        requestMessage.setWill(message.isWill());
        requestMessage.setDup(message.isDup());
        requestMessage.setRetain(message.isRetain());
        requestMessage.setMessageId(message.getMessageId());
        return requestMessage;
    }

}

        SimpleMqttMessage message = FastBeanCopier.copy(request, new SimpleMqttMessage());
        message.setPayload(type.write(request.getData()));
        return message;
    
<no_super_class>