java.lang.Number.byteValue()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.5k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中java.lang.Number.byteValue()方法的一些代码示例,展示了Number.byteValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Number.byteValue()方法的具体详情如下:
包路径:java.lang.Number
类名称:Number
方法名:byteValue

Number.byteValue介绍

[英]Returns this object's value as a byte. Might involve rounding and/or truncating the value, so it fits into a byte.
[中]以字节形式返回此对象的值。可能涉及舍入和/或截断值,以便将其放入一个字节。

代码示例

代码示例来源:origin: apache/incubator-dubbo

@Override
  public Object decode(Object jv) {
    if (jv instanceof Number) {
      return ((Number) jv).byteValue();
    }
    return (byte) 0;
  }
};

代码示例来源:origin: apache/incubator-dubbo

@Override
  public Object decode(Object jv) {
    if (jv instanceof Number) {
      return ((Number) jv).byteValue();
    }
    return (byte) 0;
  }
};

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Subtracts a value from the value of this instance.
 *
 * @param operand  the value to subtract, not null
 * @throws NullPointerException if the object is null
 * @since 2.2
 */
public void subtract(final Number operand) {
  this.value -= operand.byteValue();
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Constructs a new MutableByte with the specified value.
 *
 * @param value  the initial value to store, not null
 * @throws NullPointerException if the object is null
 */
public MutableByte(final Number value) {
  super();
  this.value = value.byteValue();
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Adds a value to the value of this instance.
 *
 * @param operand  the value to add, not null
 * @throws NullPointerException if the object is null
 * @since 2.2
 */
public void add(final Number operand) {
  this.value += operand.byteValue();
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Sets the value from any Number instance.
 *
 * @param value  the value to set, not null
 * @throws NullPointerException if the object is null
 */
@Override
public void setValue(final Number value) {
  this.value = value.byteValue();
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Increments this instance's value by {@code operand}; this method returns the value associated with the instance
 * immediately after the addition operation. This method is not thread safe.
 *
 * @param operand the quantity to add, not null
 * @throws NullPointerException if {@code operand} is null
 * @return the value associated with this instance after adding the operand
 * @since 3.5
 */
public byte addAndGet(final Number operand) {
  this.value += operand.byteValue();
  return value;
}

代码示例来源:origin: apache/incubator-dubbo

@Override
  public Object decode(Object jv) {
    if (jv instanceof Number) {
      return Byte.valueOf(((Number) jv).byteValue());
    }
    return (Byte) null;
  }
};

代码示例来源:origin: apache/incubator-dubbo

@Override
  public Object decode(Object jv) {
    if (jv instanceof Number) {
      return Byte.valueOf(((Number) jv).byteValue());
    }
    return (Byte) null;
  }
};

代码示例来源:origin: alibaba/druid

public static Byte castToByte(Object val) {
  if (val == null) {
    return null;
  }
  if (val instanceof Byte) {
    return (Byte) val;
  }
  if (val instanceof String) {
    return Byte.parseByte((String) val);
  }
  return ((Number) val).byteValue();
}

代码示例来源:origin: alibaba/druid

@Override
public byte getByte(int columnIndex) throws SQLException {
  Number number = (Number) getObject(columnIndex);
  if (number == null) {
    return 0;
  }
  return number.byteValue();
}

代码示例来源:origin: alibaba/druid

@Override
public byte getByte(int columnIndex) throws SQLException {
  Number number = (Number) getObject(columnIndex);
  if (number == null) {
    return 0;
  }
  return number.byteValue();
}

代码示例来源:origin: apache/incubator-dubbo

public byte getParameter(String key, byte defaultValue) {
  Number n = getNumbers().get(key);
  if (n != null) {
    return n.byteValue();
  }
  String value = getParameter(key);
  if (StringUtils.isEmpty(value)) {
    return defaultValue;
  }
  byte b = Byte.parseByte(value);
  getNumbers().put(key, b);
  return b;
}

代码示例来源:origin: apache/incubator-dubbo

public byte getParameter(String key, byte defaultValue) {
  Number n = getNumbers().get(key);
  if (n != null) {
    return n.byteValue();
  }
  String value = getParameter(key);
  if (StringUtils.isEmpty(value)) {
    return defaultValue;
  }
  byte b = Byte.parseByte(value);
  getNumbers().put(key, b);
  return b;
}

代码示例来源:origin: apache/incubator-dubbo

public byte getMethodParameter(String method, String key, byte defaultValue) {
  String methodKey = method + "." + key;
  Number n = getNumbers().get(methodKey);
  if (n != null) {
    return n.byteValue();
  }
  String value = getMethodParameter(method, key);
  if (StringUtils.isEmpty(value)) {
    return defaultValue;
  }
  byte b = Byte.parseByte(value);
  getNumbers().put(methodKey, b);
  return b;
}

代码示例来源:origin: apache/incubator-dubbo

public byte getMethodParameter(String method, String key, byte defaultValue) {
  String methodKey = method + "." + key;
  Number n = getNumbers().get(methodKey);
  if (n != null) {
    return n.byteValue();
  }
  String value = getMethodParameter(method, key);
  if (StringUtils.isEmpty(value)) {
    return defaultValue;
  }
  byte b = Byte.parseByte(value);
  getNumbers().put(methodKey, b);
  return b;
}

代码示例来源:origin: prestodb/presto

@Override
public byte getByte(String columnLabel)
    throws SQLException
{
  return toNumber(column(columnLabel)).byteValue();
}

代码示例来源:origin: prestodb/presto

@Override
public byte getByte(int columnIndex)
    throws SQLException
{
  return toNumber(column(columnIndex)).byteValue();
}

代码示例来源:origin: prestodb/presto

protected final byte _parseBytePrimitive(JsonParser p, DeserializationContext ctxt)
  throws IOException
{
  int value = _parseIntPrimitive(p, ctxt);
  // So far so good: but does it fit?
  if (_byteOverflow(value)) {
    Number v = (Number) ctxt.handleWeirdStringValue(_valueClass, String.valueOf(value),
        "overflow, value cannot be represented as 8-bit value");
    return _nonNullNumber(v).byteValue();
  }
  return (byte) value;
}

代码示例来源:origin: redisson/redisson

protected final byte _parseBytePrimitive(JsonParser p, DeserializationContext ctxt)
  throws IOException
{
  int value = _parseIntPrimitive(p, ctxt);
  // So far so good: but does it fit?
  if (_byteOverflow(value)) {
    Number v = (Number) ctxt.handleWeirdStringValue(_valueClass, String.valueOf(value),
        "overflow, value cannot be represented as 8-bit value");
    return _nonNullNumber(v).byteValue();
  }
  return (byte) value;
}

相关文章