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

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

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

Numbers.primitiveToWrapper介绍

[英]Changes a primitive class to its wrapper (for example int to Integer). If the specified class is not a primitive type, then it is returned unchanged.
[中]将基元类更改为其包装器(例如int到Integer)。如果指定的类不是基元类型,那么它将原封不动地返回。

代码示例

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

/**
 * Returns the elements of the given collection as an array. This method can be used when the {@code valueClass}
 * argument is not known at compile-time. If the {@code valueClass} is known at compile-time, then callers should
 * use {@link Collection#toArray(Object[])} instead.
 *
 * @param  <T>         the compile-time value of {@code valueClass}.
 * @param  collection  the collection from which to get the elements.
 * @param  valueClass  the runtime type of collection elements.
 * @return the collection elements as an array, or {@code null} if {@code collection} is null.
 *
 * @since 0.6
 */
@SuppressWarnings("unchecked")
public static <T> T[] toArray(final Collection<T> collection, final Class<T> valueClass) {
  assert Numbers.primitiveToWrapper(valueClass) == valueClass : valueClass;
  if (collection != null) {
    return collection.toArray((T[]) Array.newInstance(valueClass, collection.size()));
  }
  return null;
}

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

/**
 * Returns the elements of the given collection as an array. This method can be used when the {@code valueClass}
 * argument is not known at compile-time. If the {@code valueClass} is known at compile-time, then callers should
 * use {@link Collection#toArray(Object[])} instead.
 *
 * @param  <T>         the compile-time value of {@code valueClass}.
 * @param  collection  the collection from which to get the elements.
 * @param  valueClass  the runtime type of collection elements.
 * @return the collection elements as an array, or {@code null} if {@code collection} is null.
 *
 * @since 0.6
 *
 * @todo Remove after migration to JDK11.
 */
@SuppressWarnings("unchecked")
public static <T> T[] toArray(final Collection<T> collection, final Class<T> valueClass) {
  assert Numbers.primitiveToWrapper(valueClass) == valueClass : valueClass;
  if (collection != null) {
    return collection.toArray((T[]) Array.newInstance(valueClass, collection.size()));
  }
  return null;
}

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

/**
 * Creates a new converter for the given source and target classes.
 *
 * @param  sourceClass  the {@linkplain #getSourceClass() source class}.
 * @param  targetClass  the {@linkplain #getTargetClass() target class}.
 * @param  converter    the converter for array elements. The source and target types shall be
 *                      the array component types of {@code <S>} and {@code <T>}.
 */
ArrayConverter(final Class<S> sourceClass, final Class<T> targetClass, final ObjectConverter<?,?> converter) {
  super(sourceClass, targetClass);
  assert converter.getSourceClass().isAssignableFrom(Numbers.primitiveToWrapper(sourceClass.getComponentType())) : sourceClass;
  assert Numbers.primitiveToWrapper(targetClass.getComponentType()).isAssignableFrom(converter.getTargetClass()) : targetClass;
  this.converter = converter;
}

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

/**
 * Creates a new converter for the given source and target classes.
 *
 * @param  sourceClass  the {@linkplain #getSourceClass() source class}.
 * @param  targetClass  the {@linkplain #getTargetClass() target class}.
 * @param  converter    the converter for array elements. The source and target types shall be
 *                      the array component types of {@code <S>} and {@code <T>}.
 */
ArrayConverter(final Class<S> sourceClass, final Class<T> targetClass, final ObjectConverter<?,?> converter) {
  super(sourceClass, targetClass);
  assert converter.getSourceClass().isAssignableFrom(Numbers.primitiveToWrapper(sourceClass.getComponentType())) : sourceClass;
  assert Numbers.primitiveToWrapper(targetClass.getComponentType()).isAssignableFrom(converter.getTargetClass()) : targetClass;
  this.converter = converter;
}

代码示例来源:origin: Geomatys/geotoolkit

Numbers.primitiveToWrapper(valueClass.getComponentType()) : valueClass), (Number) minimum, true, (Number) maximum, true, unit) :
(minimum != null || maximum != null) ? new Range(valueClass, minimum, true, maximum, true) : null,
validValues, defaultValue);

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

return ObjectConverters.convert(value, URI.class);
final Class<?> type = Numbers.primitiveToWrapper(value.getClass().getComponentType());
if (type != null && Number.class.isAssignableFrom(type)) {
  if (Numbers.isInteger(type)) {

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

return ObjectConverters.convert(value, URI.class);
final Class<?> type = Numbers.primitiveToWrapper(value.getClass().getComponentType());
if (type != null && Number.class.isAssignableFrom(type)) {
  if (Numbers.isInteger(type)) {

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

/**
 * Tests {@link Numbers#primitiveToWrapper(Class)}.
 */
@Test
public void testPrimitiveToWrapper() {
  assertEquals(Byte   .class, primitiveToWrapper(Byte   .TYPE));
  assertEquals(Short  .class, primitiveToWrapper(Short  .TYPE));
  assertEquals(Integer.class, primitiveToWrapper(Integer.TYPE));
  assertEquals(Long   .class, primitiveToWrapper(Long   .TYPE));
  assertEquals(Float  .class, primitiveToWrapper(Float  .TYPE));
  assertEquals(Double .class, primitiveToWrapper(Double .TYPE));
  assertEquals(Byte   .class, primitiveToWrapper(Byte   .class));
  assertEquals(Short  .class, primitiveToWrapper(Short  .class));
  assertEquals(Integer.class, primitiveToWrapper(Integer.class));
  assertEquals(Long   .class, primitiveToWrapper(Long   .class));
  assertEquals(Float  .class, primitiveToWrapper(Float  .class));
  assertEquals(Double .class, primitiveToWrapper(Double .class));
}

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

elementType = Classes.boundOfParameterizedProperty(getter);
elementTypes[i] = Numbers.primitiveToWrapper(elementType);

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

targetType = Numbers.primitiveToWrapper(targetType);
} else {

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

elementTypes[i] = Numbers.primitiveToWrapper(elementType);

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

assert valueDomain.getElementType() == (isArray ? Numbers.primitiveToWrapper(valueClass.getComponentType()) : valueClass) : valueDomain;
final int length = isArray ? Array.getLength(convertedValue) : 1;
for (int i=0; i<length; i++) {

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

assert valueDomain.getElementType() == Numbers.primitiveToWrapper(valueClass.getComponentType()) : valueDomain;
final int length = Array.getLength(convertedValue);
for (int i=0; i<length; i++) {

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

componentType = Numbers.primitiveToWrapper(componentType);
for (int i=0; i<length; i++) {
  Number n = (Number) Array.get(value, i);

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

componentType = Numbers.primitiveToWrapper(componentType);
for (int i=0; i<length; i++) {
  Number n = (Number) Array.get(value, i);

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

if (targetComponent != null) {
  converter = new ArrayConverter<>(sourceClass, targetClass, find(
      Numbers.primitiveToWrapper(sourceComponent),
      Numbers.primitiveToWrapper(targetComponent)));
  put(key, converter);
  return converter;

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

if (targetComponent != null) {
  converter = new ArrayConverter<>(sourceClass, targetClass, find(
      Numbers.primitiveToWrapper(sourceComponent),
      Numbers.primitiveToWrapper(targetComponent)));
  put(key, converter);
  return converter;

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

Class<?> componentType = valueClass.getComponentType();
if (componentType != null) {
  componentType = Numbers.primitiveToWrapper(componentType);
} else {
  componentType = valueClass;

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

Class<?> componentType = valueClass.getComponentType();
if (componentType != null) {
  componentType = Numbers.primitiveToWrapper(componentType);
} else {
  componentType = valueClass;

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

final Class<?> propertyType = Numbers.primitiveToWrapper(accessor.type(i, TypeValuePolicy.PROPERTY_TYPE));
final Class<?>  elementType = Numbers.primitiveToWrapper(accessor.type(i, TypeValuePolicy.ELEMENT_TYPE));
assertNotNull(testingMethod, propertyType);
assertNotNull(testingMethod, elementType);

相关文章