List of usage examples for java.util.stream IntStream range
public static IntStream range(int startInclusive, int endExclusive)
From source file:com.nebhale.springone2014.repository.InMemoryGameRepository.java
private Collection<Door> createDoors() { int winner = this.random.nextInt(3); return IntStream.range(0, 3).mapToObj(index -> { Long id = this.idGenerator.getAndIncrement(); DoorContent content = (index == winner) ? DoorContent.BICYCLE : DoorContent.SMALL_FURRY_ANIMAL; return new Door(id, content); }).collect(Collectors.toList()); }
From source file:com.github.horrorho.inflatabledonkey.cloud.clients.AssetsClient.java
static List<String> manifestIDs(Manifest manifest) { return IntStream.range(0, manifest.count()).mapToObj(i -> manifest.id() + ":" + i) .collect(Collectors.toList()); }
From source file:com.abixen.platform.service.businessintelligence.multivisualization.service.impl.AbstractDatabaseService.java
public List<String> getColumns(Connection connection, String tableName) { List<String> columns = new ArrayList<>(); try {/* w w w. j a v a 2 s . c om*/ ResultSetMetaData rsmd = getDatabaseMetaData(connection, tableName); int columnCount = rsmd.getColumnCount(); IntStream.range(1, columnCount + 1).forEach(i -> { try { columns.add(rsmd.getColumnName(i)); } catch (SQLException e) { e.printStackTrace(); } }); } catch (SQLException e) { e.printStackTrace(); } return columns; }
From source file:com.github.mrenou.jacksonatic.internal.AnnotatedClassLogger.java
private static void logConstructorAnnotations(AnnotatedClass annotatedClass, StringBuilder sb) { stream(annotatedClass.getConstructors()) .filter(annotatedConstructor -> hasAnnotationOrParameterAnnotation(annotatedConstructor)) .forEach(annotatedConstructor -> { List<Class<?>> parameterTypes = IntStream.range(0, annotatedConstructor.getParameterCount()) .mapToObj(index -> annotatedConstructor.getRawParameterType(index)) .collect(Collectors.toList()); sb.append("> Constructor[" + methodSignature(annotatedClass.getAnnotated().getSimpleName(), parameterTypes) + "] : " + annotationsItToStr(annotatedConstructor.annotations())).append(ln); logParameters(sb, annotatedConstructor); });//from w w w. j av a 2 s . com }
From source file:org.apache.sysml.runtime.controlprogram.paramserv.ParamservUtils.java
/** * Deep copy the list object//from w ww. j ava 2 s. com * * @param lo list object * @return a new copied list object */ public static ListObject copyList(ListObject lo) { if (lo.getLength() == 0) { return lo; } List<Data> newData = IntStream.range(0, lo.getLength()).mapToObj(i -> { Data oldData = lo.slice(i); if (oldData instanceof MatrixObject) { MatrixObject mo = (MatrixObject) oldData; return sliceMatrix(mo, 1, mo.getNumRows()); } else if (oldData instanceof ListObject || oldData instanceof FrameObject) { throw new DMLRuntimeException("Copy list: does not support list or frame."); } else { return oldData; } }).collect(Collectors.toList()); return new ListObject(newData, lo.getNames()); }
From source file:com.enitalk.controllers.youtube.CalendarTest.java
private static TreeMultimap<DateTime, DateTime> getPeriodSet(int from, int to) { TreeMultimap<DateTime, DateTime> multimap = TreeMultimap.create(); DateTime now = new DateTime(); Integer[] today = IntStream.range(now.hourOfDay().get() + 1, to + 1).boxed().toArray(Integer[]::new); DateTime zz = now.hourOfDay().setCopy(0).minuteOfDay().setCopy(0).secondOfDay().setCopy(0).millisOfSecond() .setCopy(0);/*from ww w. j a v a 2s .co m*/ for (Integer h : today) { multimap.put(zz, zz.hourOfDay().setCopy(h)); } Integer[] fullDay = IntStream.range(from, to + 1).boxed().toArray(Integer[]::new); for (int i = 1; i < 5; i++) { for (Integer h : fullDay) { DateTime zeroDay = now.plusDays(i).hourOfDay().setCopy(0).minuteOfDay().setCopy(0).secondOfDay() .setCopy(0).millisOfSecond().setCopy(0); multimap.put(zeroDay, zeroDay.hourOfDay().setCopy(h)); } } return multimap; }
From source file:org.jodconverter.office.SimpleOfficeManager.java
@Override protected SimpleOfficeManagerPoolEntry[] createPoolEntries() { return IntStream.range(0, poolSize) .mapToObj(i -> new SimpleOfficeManagerPoolEntry((SimpleOfficeManagerPoolEntryConfig) config)) .toArray(SimpleOfficeManagerPoolEntry[]::new); }
From source file:org.esa.s3tbx.olci.radiometry.rayleigh.SpikeInterpolation.java
public static double getUpperValue(double[] doubles, double val) { final List<Double> xMin = new ArrayList<>(); int length = doubles.length; IntStream.range(0, length).forEach(i -> { double v = doubles[i]; if (v >= val) { xMin.add(v);// www. j av a 2 s.com } }); double[] allMax = Doubles.toArray(xMin); if (allMax.length == 0) { throw new IllegalArgumentException("Can fine the closest max value of " + val); } return Doubles.min(allMax); }
From source file:example.Application.java
/** * Creates a few sample users.//from w ww.j av a 2s. c o m */ @PostConstruct public void init() { IntStream.range(0, 41).forEach(index -> { userManagement.register(new Username("user" + index), Password.raw("foobar")); }); }
From source file:org.obiba.mica.web.rest.security.CurrentSessionResource.java
@GET public Mica.SessionDto get() { Subject subject = SecurityUtils.getSubject(); Mica.SessionDto.Builder builder = Mica.SessionDto.newBuilder() // .setUsername(subject.getPrincipal().toString()); List<String> roles = // Arrays.asList(Roles.MICA_ADMIN, Roles.MICA_REVIEWER, Roles.MICA_EDITOR, Roles.MICA_DAO, Roles.MICA_USER); // boolean[] result = subject.hasRoles(roles); IntStream.range(0, result.length).filter(i -> result[i]).forEach(i -> builder.addRoles(roles.get(i))); return builder.build(); }