List of usage examples for java.util Arrays stream
public static DoubleStream stream(double[] array)
From source file:de.sainth.recipe.backend.rest.controller.LogoutController.java
@RequestMapping() @ResponseStatus(HttpStatus.NO_CONTENT)/* w w w . j a v a 2 s . c om*/ void logout(HttpServletRequest request, HttpServletResponse response) { if ("/logout".equals(request.getServletPath())) { Optional<Cookie> cookie = Arrays.stream(request.getCookies()) .filter(c -> "recipe_bearer".equals(c.getName())).findFirst(); if (cookie.isPresent()) { Cookie c = cookie.get(); c.setValue(""); c.setPath("/"); c.setMaxAge(0); response.addCookie(c); } response.setStatus(HttpServletResponse.SC_NO_CONTENT); } }
From source file:ija.ija2015.homework2.Homework2Test.java
@Test public void testGame() { System.out.println("Game"); int size = 8; ReversiRules rules = new ReversiRules(size); Board board = new Board(rules); Game game = new Game(board); Player p1 = new Player(true); Player p2 = new Player(false); game.addPlayer(p1);//ww w.ja va2s . c o m game.addPlayer(p2); Field[][] save = new Field[size + 2][size + 2]; Field[][] load = null; load = game.getBoard().saveFields(); //save = SerializationUtils.clone(load); /*Cloner cloner = new Cloner(); save = cloner.deepClone(load);*/ /* for(int i = 0; i <= size +1; i++){ //System.arraycopy(load[i], 0, save[i], 0, 10); save[i] = load[i].clone(); }*/ save = Arrays.stream(load).map(x -> x.clone()).toArray(Field[][]::new); System.out.println("save " + save[4][5].getDisk()); //System.out.println(game.getBoard().getField(4, 5).getDisk()); Field f2 = game.getBoard().getField(4, 6); assertTrue("Umisteni kamene.", game.currentPlayer().putDisk(f2)); System.out.println("save " + save[4][5].getDisk()); //System.out.println(game.getBoard().getField(4, 5).getDisk()); /*for(int i = 1; i <= 8; i++){ for(int j = 1; j <= 8; j++){ System.out.print(" " +game.getBoard().getField(i, j).getDisk() + " |"); } System.out.println(); } System.out.println(); //game.getBoard().loadFields(save.get(0)); for(int i = 1; i <= 8; i++){ for(int j = 1; j <= 8; j++){ System.out.print(" " +game.getBoard().getField(i, j).getDisk() + " |"); } System.out.println(); } System.out.println();*/ }
From source file:com.github.jackygurui.vertxredissonrepository.repository.index.DefaultCompoundValueResolver.java
@Override public String resolve(Object value, JsonObject root, String id, String fieldName, RedissonIndex index) { AtomicReference<String> s = new AtomicReference<>(); if (StringUtils.isBlank(index.valueField())) { s.set(value instanceof String ? (String) value : Json.encode(value)); } else {//from www . j a v a2s . c om s.set(root.getString(index.valueField())); } Arrays.stream(index.compoundIndexFields()).forEach( e -> s.set(s.get().concat(RedisRepository.DEFAULT_SEPERATOR).concat(root.getValue(e).toString()))); return s.get().concat(RedisRepository.DEFAULT_SEPERATOR).concat(id); }
From source file:co.runrightfast.vertx.core.RunRightFastVerticleMetrics.java
static String metricName(@NonNull final MetricType metricType, final String name, final String... names) { checkArgument(StringUtils.isNotBlank(name)); if (names != null) { checkArgument(!Arrays.stream(names).filter(StringUtils::isBlank).findFirst().isPresent(), "any of the names cannot be blank"); }/*w ww. j av a 2 s .co m*/ final StringBuilder sb = new StringBuilder(64); sb.append(metricType.name()).append('.').append(name); Arrays.stream(names).forEach(n -> sb.append('.').append(n)); return sb.toString(); }
From source file:org.obiba.mica.dataset.DatasetCacheResolver.java
@Override public Collection<? extends Cache> resolveCaches( CacheOperationInvocationContext<?> cacheOperationInvocationContext) { Collection<Cache> res = Lists.newArrayList(); Optional<Object> dataset = Arrays.stream(cacheOperationInvocationContext.getArgs()) .filter(o -> o instanceof Dataset).findFirst(); if (dataset.isPresent()) { String cacheName = "dataset-" + ((Dataset) dataset.get()).getId(); Cache datasetCache = springCacheManager.getCache(cacheName); if (datasetCache == null) { CacheConfiguration conf = cacheManager.getEhcache("dataset-variables").getCacheConfiguration() .clone();//from w w w. j ava 2 s. co m conf.setName(cacheName); cacheManager.addCache(new net.sf.ehcache.Cache(conf)); net.sf.ehcache.Cache cache = cacheManager.getCache(cacheName); cacheManager.replaceCacheWithDecoratedCache(cache, InstrumentedEhcache.instrument(metricRegistry, cache)); datasetCache = new EhCacheCache(cacheManager.getEhcache(cacheName)); } res.add(datasetCache); } return res; }
From source file:io.sqp.schemamatcher.fieldmatchers.ItemsSchemaArrayMatcher.java
public boolean isCompatibleToSchema(JsonNode otherSchema) { return Arrays.stream(_schemaMatchers).allMatch(sm -> sm.isCompatibleTo(otherSchema)) && _additionalField.isCompatibleTo(otherSchema); }
From source file:org.esbtools.eventhandler.lightblue.testing.TestMetadataJson.java
public static LightblueExternalResource.LightblueTestMethods forEntities(Class<?>... entityClasses) { return new LightblueExternalResource.LightblueTestMethods() { @Override/*ww w.ja v a2 s . c o m*/ public JsonNode[] getMetadataJsonNodes() throws Exception { return Arrays.stream(entityClasses).map(TestMetadataJson::entityClassAsTestableJsonMetadata) .collect(Collectors.toList()).toArray(new JsonNode[entityClasses.length]); } }; }
From source file:co.runrightfast.vertx.core.eventbus.EventBusAddress.java
/** * Address format follows a URI path convention, but prefixes the path with 'runrightfast'. * * e.g., eventBusAddress("path1","path2","path3") returns "/runrightfast/path1/path2/path3" * * * @param path REQUIRED//from w w w .j a v a 2 s . com * @param paths OPTIONAL * @return eventbus address */ public static String runrightfastEventBusAddress(final String path, final String... paths) { checkArgument(isNotBlank(path)); final StringBuilder sb = new StringBuilder(128).append('/').append(RUNRIGHTFAST).append('/').append(path); if (ArrayUtils.isNotEmpty(paths)) { checkArgument(!Arrays.stream(paths).filter(StringUtils::isBlank).findFirst().isPresent()); sb.append('/').append(String.join("/", paths)); } return sb.toString(); }
From source file:edu.brandeis.ggen.GGenCommand.java
public String generateGraphviz() throws GGenException { ProcessBuilder pb = new ProcessBuilder(); List<String> command = new LinkedList<>(); command.add(GGEN_PATH);//ww w. ja va2 s . com Arrays.stream(args.split(" ")).forEach(command::add); try { Process p = pb.command(command).start(); if (this.input != null) p.getOutputStream().write(this.input.generateGraphviz().getBytes()); p.getOutputStream().close(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); IOUtils.copy(p.getInputStream(), bos); return new String(bos.toByteArray()); } catch (IOException e) { throw new GGenException( "Could not launch the ggen command. Check that the GGenCommand.GGEN_PATH static variable is correctly set for your system. Message: " + e.getMessage()); } }
From source file:com.simiacryptus.util.lang.CodeUtil.java
/** * Find file file.//from w w w . jav a 2 s.c o m * * @param callingFrame the calling frame * @return the file */ @javax.annotation.Nonnull public static File findFile(@javax.annotation.Nonnull final StackTraceElement callingFrame) { @javax.annotation.Nonnull final String[] packagePath = callingFrame.getClassName().split("\\."); @javax.annotation.Nonnull final String path = Arrays.stream(packagePath).limit(packagePath.length - 1) .collect(Collectors.joining(File.separator)) + File.separator + callingFrame.getFileName(); return com.simiacryptus.util.lang.CodeUtil.findFile(path); }