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

io.quarkus.websockets.next.UserData Maven / Gradle / Ivy

There is a newer version: 3.17.2
Show newest version
package io.quarkus.websockets.next;

/**
 * Mutable user data associated with a connection. Implementations must be thread-safe.
 */
public interface UserData {

    /**
     *
     * @param 
     * @param key
     * @return the value or {@code null} if no mapping is found
     */
     VALUE get(TypedKey key);

    /**
     * Associates the specified value with the specified key. An old value is replaced by the specified value.
     *
     * @param 
     * @param key
     * @param value
     * @return the previous value associated with {@code key}, or {@code null} if no mapping exists
     */
     VALUE put(TypedKey key, VALUE value);

    /**
     *
     * @param 
     * @param key
     */
     VALUE remove(TypedKey key);

    int size();

    void clear();

    /**
     * @param  The type this key is used for.
     */
    record TypedKey(String value) {

        public static TypedKey forInt(String key) {
            return new TypedKey<>(key);
        }

        public static TypedKey forLong(String key) {
            return new TypedKey<>(key);
        }

        public static TypedKey forString(String key) {
            return new TypedKey<>(key);
        }

        public static TypedKey forBoolean(String key) {
            return new TypedKey<>(key);
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy