当前位置: 首页>>代码示例>>Java>>正文


Java Ints.toArray方法代码示例

本文整理汇总了Java中com.google.common.primitives.Ints.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java Ints.toArray方法的具体用法?Java Ints.toArray怎么用?Java Ints.toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.primitives.Ints的用法示例。


在下文中一共展示了Ints.toArray方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: provideExtractorForValue

import com.google.common.primitives.Ints; //导入方法依赖的package包/类
private <T> ValueExtractor provideExtractorForValue(Class<T> clazz, int target, List<String> chainOfProperties) {
    Class<?> propertyClass = clazz;
    List<Integer> indices = Lists.newArrayList();

    for (String property : chainOfProperties) {
        Field field;
        try {
            field = clazz.getDeclaredField(property);
        } catch (NoSuchFieldException e) {
            throw new InvalidQueryException(e);
        }

        PortableProperty portablePropertyAnnotation = field.getAnnotation(PortableProperty.class);
        if (portablePropertyAnnotation == null) {
            throw new InvalidQueryException("");
        }

        // TODO add support for customs codecs some day ;)
        int index = portablePropertyAnnotation.value();
        indices.add(index);
        propertyClass = field.getDeclaringClass();
    }

    return new PofExtractor<>(propertyClass, new SimplePofPath(Ints.toArray(indices)), target);
}
 
开发者ID:michalwojciechowski,项目名称:coherence-sql,代码行数:26,代码来源:PofExtractorFactory.java

示例2: toArray

import com.google.common.primitives.Ints; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"}) // NOTE: We assume the component type matches the list
private Object toArray(Class<?> componentType, List<Object> values) {
    if (componentType == boolean.class) {
        return Booleans.toArray((Collection) values);
    } else if (componentType == byte.class) {
        return Bytes.toArray((Collection) values);
    } else if (componentType == short.class) {
        return Shorts.toArray((Collection) values);
    } else if (componentType == int.class) {
        return Ints.toArray((Collection) values);
    } else if (componentType == long.class) {
        return Longs.toArray((Collection) values);
    } else if (componentType == float.class) {
        return Floats.toArray((Collection) values);
    } else if (componentType == double.class) {
        return Doubles.toArray((Collection) values);
    } else if (componentType == char.class) {
        return Chars.toArray((Collection) values);
    }
    return values.toArray((Object[]) Array.newInstance(componentType, values.size()));
}
 
开发者ID:TNG,项目名称:ArchUnit,代码行数:22,代码来源:JavaClassProcessor.java

示例3: getZoomLevels

import com.google.common.primitives.Ints; //导入方法依赖的package包/类
private int[] getZoomLevels() {
  final List<Integer> zoomLevels = new ArrayList<>();
  final File[] files = directory.listFiles();

  if (files == null) {
    return new int[]{};
  }

  final Pattern pattern = Pattern.compile("^([0-9]|1[0-9]|2[0-2])$");
  for (final File file : files) {
    final String fileName = file.getName();
    final Matcher matcher = pattern.matcher(fileName);
    if (matcher.matches()) {
      final int value = Integer.parseInt(matcher.group());
      zoomLevels.add(value);
    }
  }
  final int[] result = Ints.toArray(zoomLevels);
  Arrays.sort(result);
  return result;
}
 
开发者ID:OrdnanceSurvey,项目名称:vt-support,代码行数:22,代码来源:StorageImpl.java

示例4: testScale_index_compute_intVarargs

import com.google.common.primitives.Ints; //导入方法依赖的package包/类
public void testScale_index_compute_intVarargs() {
  int[] dataset = Ints.toArray(SIXTEEN_SQUARES_INTEGERS);
  assertThat(Quantiles.scale(10).index(1).compute(dataset))
      .isWithin(ALLOWED_ERROR)
      .of(SIXTEEN_SQUARES_DECILE_1);
  assertThat(dataset).asList().isEqualTo(SIXTEEN_SQUARES_INTEGERS);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:QuantilesTest.java

示例5: testScale_indexes_varargs_compute_intVarargs

import com.google.common.primitives.Ints; //导入方法依赖的package包/类
public void testScale_indexes_varargs_compute_intVarargs() {
  int[] dataset = Ints.toArray(SIXTEEN_SQUARES_INTEGERS);
  assertThat(Quantiles.scale(10).indexes(0, 10, 5, 1, 8, 1).compute(dataset))
      .comparingValuesUsing(QUANTILE_CORRESPONDENCE)
      .containsExactly(
          0, SIXTEEN_SQUARES_MIN,
          10, SIXTEEN_SQUARES_MAX,
          5, SIXTEEN_SQUARES_MEDIAN,
          1, SIXTEEN_SQUARES_DECILE_1,
          8, SIXTEEN_SQUARES_DECILE_8);
  assertThat(dataset).asList().isEqualTo(SIXTEEN_SQUARES_INTEGERS);
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:13,代码来源:QuantilesTest.java

示例6: finishPage

import com.google.common.primitives.Ints; //导入方法依赖的package包/类
private void finishPage() {
    // Create and add the page
    IGuideElement[] pageElements = elems.toArray(new IGuideElement[elems.size()]);
    int[] pageStartPoints = Ints.toArray(startPoints);
    int[] pageEndPoints = Ints.toArray(endPoints);
    int[] translationPoints = Ints.toArray(heights);
    pages.add(new GuidePage(guide, pageElements, pageStartPoints, pageEndPoints, translationPoints));

    // Reset all values
    elems.clear();
    heights.clear();
    startPoints.clear();
    endPoints.clear();
    y = 0;
}
 
开发者ID:Guichaguri,项目名称:ProjectEon,代码行数:16,代码来源:GuidePage.java

示例7: testScale_indexes_varargs_compute_intVarargs

import com.google.common.primitives.Ints; //导入方法依赖的package包/类
public void testScale_indexes_varargs_compute_intVarargs() {
  int[] dataset = Ints.toArray(SIXTEEN_SQUARES_INTEGERS);
  ImmutableMap<Integer, Double> expected = ImmutableMap.of(
      0, SIXTEEN_SQUARES_MIN,
      10, SIXTEEN_SQUARES_MAX,
      5, SIXTEEN_SQUARES_MEDIAN,
      1, SIXTEEN_SQUARES_DECILE_1,
      8, SIXTEEN_SQUARES_DECILE_8
      );
  assertQuantilesMap(expected, Quantiles.scale(10).indexes(0, 10, 5, 1, 8, 1).compute(dataset));
  assertDatasetInOrder(SIXTEEN_SQUARES_INTEGERS, dataset);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:13,代码来源:QuantilesTest.java

示例8: Metadata

import com.google.common.primitives.Ints; //导入方法依赖的package包/类
private Metadata(int lines, List<Integer> originalLineOffsets, int lastValidOffset) {
  this.lines = lines;
  this.originalLineOffsets = Ints.toArray(originalLineOffsets);
  this.lastValidOffset = lastValidOffset;
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:6,代码来源:FileMetadata.java

示例9: deserialize

import com.google.common.primitives.Ints; //导入方法依赖的package包/类
@Override public int[] deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException {
    List<Integer> list = value.getList(ttb);
    return Ints.toArray(list);
}
 
开发者ID:NucleusPowered,项目名称:Neutrino,代码行数:5,代码来源:IntArrayTypeSerialiser.java

示例10: testScale_index_compute_intVarargs

import com.google.common.primitives.Ints; //导入方法依赖的package包/类
public void testScale_index_compute_intVarargs() {
  int[] dataset = Ints.toArray(SIXTEEN_SQUARES_INTEGERS);
  assertQuantile(1, SIXTEEN_SQUARES_DECILE_1, Quantiles.scale(10).index(1).compute(dataset));
  assertDatasetInOrder(SIXTEEN_SQUARES_INTEGERS, dataset);
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:6,代码来源:QuantilesTest.java


注:本文中的com.google.common.primitives.Ints.toArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。