當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。