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

io.rocketbase.commons.model.HasKeyValue Maven / Gradle / Ivy

There is a newer version: 4.4.1
Show newest version
package io.rocketbase.commons.model;

import java.util.Map;

public interface HasKeyValue {

    /**
     * @return an immutable map so that changes should only be done by add/remove KeyValue
     */
    Map getKeyValues();

    /**
     * checks if user has key (ignore cases)
     *
     * @param key name of key
     * @return true when exists
     */
    default boolean hasKeyValue(String key) {
        return getKeyValues() != null && key != null && getKeyValues().containsKey(key.toLowerCase());
    }

    /**
     * search for value of given key
     *
     * @param key name of key (ignore cases)
     * @return value or null when not found
     */
    default String getKeyValue(String key) {
        return getKeyValues() != null && key != null ? getKeyValues().getOrDefault(key.toLowerCase(), null) : null;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy