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

org.jetlinks.rule.engine.api.scope.ScopeCounter Maven / Gradle / Ivy

The newest version!
package org.jetlinks.rule.engine.api.scope;

import reactor.core.publisher.Mono;

/**
 * 计数器
 *
 * @author zhouhao
 */
public interface ScopeCounter {

    /**
     * 递增 1
     *
     * @return 自增后的值
     */
    default Mono inc() {
        return inc(1);
    }

    /**
     * 递减 1
     *
     * @return 递减后等值
     */
    default Mono dec() {
        return dec(1);
    }

    /**
     * 递增 n
     *
     * @return 自增后的值
     */
    Mono inc(double n);

    /**
     * 递减 n
     *
     * @return 递减后等值
     */
    Mono dec(double n);

    /**
     * 获取当前值
     *
     * @return 当前值
     */
    Mono get();

    /**
     * 设置值
     *
     * @param value 新的值
     * @return 旧的值
     */
    Mono set(double value);

    /**
     * 设置值并返回最新的值
     *
     * @param value 值
     * @return 最新的值
     */
    Mono setAndGet(double value);

    /**
     * 获取值然后更新
     *
     * @param value 值
     * @return 更新前的值
     */
    Mono getAndSet(double value);

    /**
     * 删除计数器
     *
     * @return 计数器值
     */
    Mono remove();

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy