it.auties.whatsapp.model.message.model.MessageStatus Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of whatsappweb4j Show documentation
Show all versions of whatsappweb4j Show documentation
Standalone fully-featured Whatsapp Web API for Java and Kotlin
package it.auties.whatsapp.model.message.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import it.auties.protobuf.base.ProtobufMessage;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.experimental.Accessors;
import java.util.Arrays;
import java.util.Optional;
/**
* The constants of this enumerated type describe the various types of status of a {@link Message}
*/
@AllArgsConstructor
@Accessors(fluent = true)
public enum MessageStatus implements ProtobufMessage {
/**
* Erroneous status(no ticks)
*/
ERROR(0),
/**
* Pending status(no ticks)
*/
PENDING(1),
/**
* Acknowledged by the server(one tick)
*/
SERVER_ACK(2),
/**
* Delivered(two ticks)
*/
DELIVERED(3),
/**
* Read(two blue ticks)
*/
READ(4),
/**
* Played(two blue ticks)
*/
PLAYED(5);
@Getter
private final int index;
public static Optional of(String name) {
return name == null ? Optional.empty() : Arrays.stream(values())
.filter(entry -> name.toLowerCase().contains(entry.name().toLowerCase()))
.findFirst();
}
@JsonCreator
public static MessageStatus of(int index) {
return Arrays.stream(values()).filter(entry -> entry.index() == index).findFirst().orElse(ERROR);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy