Example usage for java.util.stream IntStream rangeClosed

List of usage examples for java.util.stream IntStream rangeClosed

Introduction

In this page you can find the example usage for java.util.stream IntStream rangeClosed.

Prototype

public static IntStream rangeClosed(int startInclusive, int endInclusive) 

Source Link

Document

Returns a sequential ordered IntStream from startInclusive (inclusive) to endInclusive (inclusive) by an incremental step of 1 .

Usage

From source file:com.netflix.imfutility.itunes.audio.ChannelsMapper.java

/**
 * Prepare channels layout by order.//from w w w  .j a  va 2  s  . c o m
 */
private void prepareChannelsByOrder() {
    SequenceTemplateParameterContext sequenceContext = contextProvider.getSequenceContext();

    channelsByOrder.clear();

    for (SequenceUUID seqUuid : sequenceContext.getUuids(SequenceType.AUDIO)) {
        ContextInfo contextInfo = new ContextInfoBuilder().setSequenceType(SequenceType.AUDIO)
                .setSequenceUuid(seqUuid).build();
        String channelsNum = sequenceContext.getParameterValue(SequenceContextParameters.CHANNELS_NUM,
                contextInfo);

        IntStream.rangeClosed(1, Integer.parseInt(channelsNum)).mapToObj(i -> Pair.of(seqUuid, i))
                .forEachOrdered(channelsByOrder::add);
    }
}

From source file:edu.artic.geneva.sync.RowProcessor.java

/**
 *  Mint a URL for the given ID value, based on an MD5-based pairtree
 *//*from  w  ww .  jav  a 2 s .co m*/
private static String buildPath(final String prefix, final String id) {

    final StringBuilder path = new StringBuilder();
    final String md5 = md5Hex(id);

    final StringJoiner joiner = new StringJoiner("/", "", "/" + md5);

    IntStream.rangeClosed(0, DEFAULT_COUNT - 1)
            .forEach(x -> joiner.add(md5.substring(x * DEFAULT_LENGTH, (x + 1) * DEFAULT_LENGTH)));

    if (!prefix.startsWith("/")) {
        path.append("/");
    }

    if (prefix.length() > 0) {
        path.append(prefix);

        if (!prefix.endsWith("/")) {
            path.append("/");
        }
    }

    path.append(joiner.toString());
    return path.toString();
}

From source file:org.ow2.proactive.workflow_catalog.rest.controller.BucketControllerIntegrationTest.java

@Test
public void testListBucketsShouldReturnSavedBuckets() {
    List<Bucket> buckets = IntStream.rangeClosed(1, 25).mapToObj(i -> new Bucket("bucket" + i))
            .collect(Collectors.toList());

    bucketRepository.save(buckets);/*from  w w w. ja  va  2 s .  c  om*/

    when().get(BUCKETS_RESOURCE).then().assertThat().statusCode(HttpStatus.SC_OK)
            .body("_embedded.bucketMetadataList", hasSize(20)).body("page.number", is(0))
            .body("page.totalElements", is(buckets.size()));
}

From source file:com.simiacryptus.util.lang.CodeUtil.java

/**
 * Gets javadoc.//from   ww  w. j a  va2s .c  o m
 *
 * @param clazz the clazz
 * @return the javadoc
 */
public static String getJavadoc(@Nullable final Class<?> clazz) {
    try {
        if (null == clazz)
            return null;
        @Nullable
        final File source = com.simiacryptus.util.lang.CodeUtil.findFile(clazz);
        if (null == source)
            return clazz.getName() + " not found";
        final List<String> lines = IOUtils.readLines(new FileInputStream(source), Charset.forName("UTF-8"));
        final int classDeclarationLine = IntStream.range(0, lines.size())
                .filter(i -> lines.get(i).contains("class " + clazz.getSimpleName())).findFirst().getAsInt();
        final int firstLine = IntStream.rangeClosed(1, classDeclarationLine).map(i -> classDeclarationLine - i)
                .filter(i -> !lines.get(i).matches("\\s*[/\\*@].*")).findFirst().orElse(-1) + 1;
        final String javadoc = lines.subList(firstLine, classDeclarationLine).stream()
                .filter(s -> s.matches("\\s*[/\\*].*")).map(s -> s.replaceFirst("^[ \t]*[/\\*]+", "").trim())
                .filter(x -> !x.isEmpty()).reduce((a, b) -> a + "\n" + b).orElse("");
        return javadoc.replaceAll("<p>", "\n");
    } catch (@javax.annotation.Nonnull final Throwable e) {
        e.printStackTrace();
        return "";
    }
}

From source file:beast.math.NumberFormatter.java

private DecimalFormat getScientificFormat() {
    final String format = "0."
            + IntStream.rangeClosed(0, sf - 1).mapToObj(i -> "#").collect(Collectors.joining()) + "E0";
    return new DecimalFormat(format);
}

From source file:cz.muni.fi.editor.database.test.NotificationDAOTest.java

@Test
public void markLarge() {
    List<Notification> list = IntStream.rangeClosed(1, 101).mapToObj(i -> {
        Notification n = new Notification();
        n.setMessage("test");
        n.setNotificationDate(LocalDateTime.now());
        n.setNotified(userDAO.getById(1L));

        notificationDAO.create(n);//from   ww  w  .jav  a  2s.  c o m
        return n;
    }).collect(Collectors.toList());

    notificationDAO.markSeen(list);

}

From source file:com.creactiviti.piper.core.task.SpelTaskEvaluator.java

private MethodExecutor range() {
    return (ctx, target, args) -> {
        List<Integer> value = IntStream.rangeClosed((int) args[0], (int) args[1]).boxed()
                .collect(Collectors.toList());
        return new TypedValue(value);
    };// w  w w.  j a  v a2 s.co  m
}

From source file:com.github.nginate.commons.testing.Unique.java

@SafeVarargs
@SuppressWarnings("varargs")
private static Stream<Character> getCharsStream(Pair<Character, Character>... fromToInclusivePairs) {
    int[] validChars = Arrays.stream(fromToInclusivePairs)
            .flatMapToInt(fromTo -> IntStream.rangeClosed(fromTo.getLeft(), fromTo.getRight())).toArray();
    return IntStream.iterate(0, i -> i + 1)
            .map(i -> validChars[i - validChars.length * (i / validChars.length)])
            .mapToObj(charCode -> (char) charCode);
}

From source file:energy.usef.dso.controller.CommonReferenceQueryResponseControllerTest.java

private List<PtuContainer> buildPtuContainers(int i) {
    return IntStream.rangeClosed(1, i).mapToObj(index -> new PtuContainer(new LocalDate(), index))
            .collect(Collectors.toList());
}