org.apache.sis.util.Numbers.valueOfNil()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(2.6k)|赞(0)|评价(0)|浏览(161)

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

Numbers.valueOfNil介绍

[英]Returns a NaN, zero, empty or null value of the given type. This method tries to return the closest value that can be interpreted as "none", which is usually not the same than "zero". More specifically:

  • If the given type is a floating point primitive type ( floator double), then this method returns Float#NaN or Double#NaNdepending on the given type.
  • If the given type is an integer primitive type or the character type ( long, int, short, byte or char), then this method returns the zero value of the given type.
  • If the given type is the boolean primitive type, then this method returns Boolean#FALSE.
  • If the given type is an array or a collection, then this method returns an empty array or collection. The given type is honored on a best effort basis.
  • For all other cases, including the wrapper classes of primitive types, this method returns null.
    Despite being defined in the Numbers class, the scope of this method has been extended to array and collection types because those objects can also be seen as mathematical concepts.
    [中]返回给定类型的NaN、zero、empty或null值。此方法尝试返回可解释为“无”的最接近值,该值通常与“零”不同。更具体地说:
    *如果给定的类型是浮点基元类型(Float或double),则此方法会在给定类型上返回Float#NaN或double#NaNdepending。
    *如果给定类型是整数基元类型或字符类型(long、int、short、byte或char),则此方法返回给定类型的零值。
    *如果给定的类型是布尔基元类型,则此方法返回布尔#FALSE。
    *如果给定类型是数组或集合,则此方法返回空数组或集合。给定的类型是在尽最大努力的基础上授予的。
    *对于所有其他情况,包括基元类型的包装器类,该方法返回null。
    尽管已在Numbers类中定义,但该方法的范围已扩展到数组和集合类型,因为这些对象也可以被视为数学概念。

代码示例

代码示例来源:origin: apache/sis

/**
 * Returns a "nil" value. This is used for creating empty ranges.
 */
private Object valueOfNil() {
  Object value = Numbers.valueOfNil(elementType);
  if (value == null) {
    if (Date.class.isAssignableFrom(elementType)) {
      value = new Date();
    } else {
      value = 0;
    }
  }
  return convert(value);
}

代码示例来源:origin: org.apache.sis.core/sis-utility

/**
 * Returns a "nil" value. This is used for creating empty ranges.
 */
private Object valueOfNil() {
  Object value = Numbers.valueOfNil(elementType);
  if (value == null) {
    if (Date.class.isAssignableFrom(elementType)) {
      value = new Date();
    } else {
      value = 0;
    }
  }
  return convert(value);
}

代码示例来源:origin: org.apache.sis.core/sis-utility

return Numbers.valueOfNil(method.getReturnType());

代码示例来源:origin: apache/sis

return Numbers.valueOfNil(method.getReturnType());

代码示例来源:origin: apache/sis

newValues[0] = Numbers.valueOfNil(targetType);

代码示例来源:origin: org.apache.sis.core/sis-metadata

newValues[0] = Numbers.valueOfNil(targetType);

代码示例来源:origin: apache/sis

final Object[] values = new Object[parameters.length];
for (int i=0; i<values.length; i++) {
  values[i] = Numbers.valueOfNil(parameters[i]);

相关文章