public class CounterItem extends Object implements LabelElement
| 限定符和类型 | 字段和说明 |
|---|---|
static cn.weforward.protocol.ext.ObjectMapper<CounterItem> |
_Mapper
映射器
|
long |
hold
同步后(中心服务器)返回的总值减去当前值的结果
|
String |
id
统计ID
|
long |
value
当前(变化中的)计数
|
| 构造器和说明 |
|---|
CounterItem(String id)
构造初始值为0的项
|
CounterItem(String id,
long value)
构造
|
| 限定符和类型 | 方法和说明 |
|---|---|
long |
addAndGet(int add)
累加指定值(为负数则是减)
|
long |
dec()
减一
|
String |
getIdForLabel()
相对于标签的项ID
|
int |
getIntValue() |
long |
getTotal()
计数项的(合并)值
|
long |
getValue()
当前(节点下的)值
|
long |
inc()
加一
|
static int |
long2int(long v)
为兼容,强制把long转为int
|
void |
set(long v)
指定绝对值
|
boolean |
syncTotal(long total)
由其它节点/主节点同步(影响hold的值)
|
String |
toString() |
public final String id
public volatile long value
public volatile long hold
public static cn.weforward.protocol.ext.ObjectMapper<CounterItem> _Mapper
public CounterItem(String id)
id - 计数项IDpublic CounterItem(String id, long value)
id - 计数项IDvalue - 初始值public long getTotal()
public long getValue()
public long inc()
public long dec()
public long addAndGet(int add)
add - 累加值(负数则为减)public void set(long v)
v - 绝对值public boolean syncTotal(long total)
total - 统计总值public int getIntValue()
public static final int long2int(long v)
v - long数值public String getIdForLabel()
LabelElementgetIdForLabel 在接口中 LabelElementCopyright © 2021. All rights reserved.