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

it.auties.whatsapp.model.contact.ContactStatus Maven / Gradle / Ivy

There is a newer version: 3.5.1
Show newest version
package it.auties.whatsapp.model.contact;

import lombok.AllArgsConstructor;
import lombok.NonNull;
import lombok.experimental.Accessors;

import java.util.Arrays;
import java.util.Optional;

/**
 * The constants of this enumerated type describe the various status that a {@link Contact} can be
 * in
 */
@AllArgsConstructor
@Accessors(fluent = true)
public enum ContactStatus {
    /**
     * When the contact is online
     */
    AVAILABLE,
    /**
     * When the contact is offline
     */
    UNAVAILABLE,
    /**
     * When the contact is writing a text message
     */
    COMPOSING,
    /**
     * When the contact is recording an audio message
     */
    RECORDING;

    private static ContactStatus of(int index) {
        return Arrays.stream(values()).filter(entry -> entry.ordinal() == index).findFirst().orElse(null);
    }

    public static Optional of(@NonNull String jsonValue) {
        return Arrays.stream(values()).filter(entry -> entry.name().equalsIgnoreCase(jsonValue)).findFirst();
    }

    /**
     * Returns the name of this enumerated constant
     *
     * @return a lowercase non-null String
     */
    public String data() {
        return name().toLowerCase();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy