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

it.auties.whatsapp.model.message.standard.ContactsMessage Maven / Gradle / Ivy

package it.auties.whatsapp.model.message.standard;

import it.auties.protobuf.annotation.ProtobufMessageName;
import it.auties.protobuf.annotation.ProtobufProperty;
import it.auties.protobuf.model.ProtobufType;
import it.auties.whatsapp.model.info.ContextInfo;
import it.auties.whatsapp.model.message.model.ContextualMessage;
import it.auties.whatsapp.model.message.model.MessageCategory;
import it.auties.whatsapp.model.message.model.MessageType;

import java.util.List;
import java.util.Optional;

/**
 * A model class that represents a message holding a list of contacts inside
 */
@ProtobufMessageName("Message.ContactsArrayMessage")
public final class ContactsMessage implements ContextualMessage {
    @ProtobufProperty(index = 1, type = ProtobufType.STRING)
    private final String name;
    @ProtobufProperty(index = 2, type = ProtobufType.OBJECT)
    private final List contacts;
    @ProtobufProperty(index = 17, type = ProtobufType.OBJECT)
    private ContextInfo contextInfo;


    public ContactsMessage(String name, List contacts, ContextInfo contextInfo) {
        this.name = name;
        this.contacts = contacts;
        this.contextInfo = contextInfo;
    }

    @Override
    public MessageType type() {
        return MessageType.CONTACT_ARRAY;
    }

    @Override
    public MessageCategory category() {
        return MessageCategory.STANDARD;
    }

    public String name() {
        return name;
    }

    public List contacts() {
        return contacts;
    }

    @Override
    public Optional contextInfo() {
        return Optional.ofNullable(contextInfo);
    }

    @Override
    public ContactsMessage setContextInfo(ContextInfo contextInfo) {
        this.contextInfo = contextInfo;
        return this;
    }

    @Override
    public String toString() {
        return "ContactsMessage[" +
                "name=" + name + ", " +
                "contacts=" + contacts + ", " +
                "contextInfo=" + contextInfo + ']';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy