本文整理了Java中java.lang.Number.longValue()
方法的一些代码示例,展示了Number.longValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Number.longValue()
方法的具体详情如下:
包路径:java.lang.Number
类名称:Number
方法名:longValue
[英]Returns this object's value as a long. Might involve rounding and/or truncating the value, so it fits into a long.
[中]
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return ((Number) jv).longValue();
}
return (long) 0;
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return ((Number) jv).longValue();
}
return (long) 0;
}
};
代码示例来源:origin: apache/incubator-dubbo
/**
* get long value.
*
* @param key key.
* @param def default value.
* @return value or default value.
*/
public long getLong(String key, long def) {
Object tmp = mMap.get(key);
return tmp != null && tmp instanceof Number ? ((Number) tmp).longValue() : def;
}
代码示例来源:origin: apache/incubator-dubbo
/**
* get long value.
*
* @param key key.
* @param def default value.
* @return value or default value.
*/
public long getLong(String key, long def) {
Object tmp = mMap.get(key);
return tmp != null && tmp instanceof Number ? ((Number) tmp).longValue() : def;
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return Long.valueOf(((Number) jv).longValue());
}
return (Long) null;
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) throws IOException {
if (jv instanceof Number) {
return BigInteger.valueOf(((Number) jv).longValue());
}
return (BigInteger) null;
}
};
代码示例来源:origin: apache/incubator-dubbo
/**
* get long value.
*
* @param index index.
* @param def default value.
* @return value or default value.
*/
public long getLong(int index, long def) {
Object tmp = mArray.get(index);
return tmp != null && tmp instanceof Number ? ((Number) tmp).longValue() : def;
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) throws IOException {
if (jv instanceof Number) {
return new AtomicLong(((Number) jv).longValue());
}
return (AtomicLong) null;
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) throws IOException {
if (jv instanceof Number) {
return BigInteger.valueOf(((Number) jv).longValue());
}
return (BigInteger) null;
}
};
代码示例来源:origin: apache/incubator-dubbo
/**
* get long value.
*
* @param index index.
* @param def default value.
* @return value or default value.
*/
public long getLong(int index, long def) {
Object tmp = mArray.get(index);
return tmp != null && tmp instanceof Number ? ((Number) tmp).longValue() : def;
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) {
if (jv instanceof Number) {
return Long.valueOf(((Number) jv).longValue());
}
return (Long) null;
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public Object decode(Object jv) throws IOException {
if (jv instanceof Number) {
return new AtomicLong(((Number) jv).longValue());
}
return (AtomicLong) null;
}
};
代码示例来源:origin: spring-projects/spring-framework
@Nullable
private Long headerToLong(@Nullable Object headerValue) {
if (headerValue instanceof Number) {
return ((Number) headerValue).longValue();
}
else if (headerValue instanceof String) {
return Long.parseLong((String) headerValue);
}
else {
return null;
}
}
代码示例来源:origin: apache/incubator-dubbo
@Override
public void encode(Object obj, JSONWriter jb) throws IOException {
jb.valueLong(((Number) obj).longValue());
}
};
代码示例来源:origin: apache/incubator-dubbo
@Override
public void encode(Object obj, JSONWriter jb) throws IOException {
jb.valueLong(((Number) obj).longValue());
}
};
代码示例来源:origin: apache/incubator-dubbo
public long getParameter(String key, long defaultValue) {
Number n = getNumbers().get(key);
if (n != null) {
return n.longValue();
}
String value = getParameter(key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
long l = Long.parseLong(value);
getNumbers().put(key, l);
return l;
}
代码示例来源:origin: apache/incubator-dubbo
public long getParameter(String key, long defaultValue) {
Number n = getNumbers().get(key);
if (n != null) {
return n.longValue();
}
String value = getParameter(key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
long l = Long.parseLong(value);
getNumbers().put(key, l);
return l;
}
代码示例来源:origin: apache/incubator-dubbo
public long getMethodParameter(String method, String key, long defaultValue) {
String methodKey = method + "." + key;
Number n = getNumbers().get(methodKey);
if (n != null) {
return n.longValue();
}
String value = getMethodParameter(method, key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
long l = Long.parseLong(value);
getNumbers().put(methodKey, l);
return l;
}
代码示例来源:origin: apache/incubator-dubbo
public long getMethodParameter(String method, String key, long defaultValue) {
String methodKey = method + "." + key;
Number n = getNumbers().get(methodKey);
if (n != null) {
return n.longValue();
}
String value = getMethodParameter(method, key);
if (StringUtils.isEmpty(value)) {
return defaultValue;
}
long l = Long.parseLong(value);
getNumbers().put(methodKey, l);
return l;
}
代码示例来源:origin: google/guava
public void testForMapWildCardWithDefault() {
Map<String, Integer> map = Maps.newHashMap();
map.put("One", 1);
map.put("Three", 3);
Number number = Double.valueOf(42);
Function<String, Number> function = Functions.forMap(map, number);
assertEquals(1, function.apply("One").intValue());
assertEquals(number, function.apply("Two"));
assertEquals(3L, function.apply("Three").longValue());
}
内容来源于网络,如有侵权,请联系作者删除!