List of usage examples for com.google.common.collect Iterables concat
public static <T> Iterable<T> concat(Iterable<? extends T> a, Iterable<? extends T> b)
From source file:javalabra.shakki.engine.player.Player.java
Player(final Board board, final Collection<Move> legalMoves, final Collection<Move> opponentsMoves) { this.board = board; this.playerKing = establishKing(); this.legalMoves = ImmutableList .copyOf(Iterables.concat(legalMoves, calculateKingCastles(legalMoves, opponentsMoves))); this.isInCheck = !Player.calculateAttacksOnTile(this.playerKing.getPiecePosition(), opponentsMoves) .isEmpty();// w w w .java 2 s.co m }
From source file:brainleg.app.engine.visitor.WebSearchStringGeneratorVisitor.java
public void visit(EData data) { Collection<ELine> lines = Lists.newArrayList(Iterables.concat(data.getHeaders(), data.getTraces())); //remove disabled lines lines = Collections2.filter(lines, new Predicate<ELine>() { public boolean apply(ELine line) { return line.enabled; }/*www . ja va2 s .c om*/ }); sb.append(Joiner.on("").join(Collections2.transform(lines, new Function<ELine, String>() { public String apply(ELine line) { return line.submissionText; } }))); }
From source file:org.gradle.api.internal.tasks.compile.incremental.AnnotationProcessorChangeProcessor.java
AnnotationProcessorChangeProcessor(CurrentCompilation current, PreviousCompilation previous) { this.jointProcessorPath = DefaultFileHierarchySet .of(Iterables.concat(current.getAnnotationProcessorPath(), previous.getAnnotationProcessorPath())); }
From source file:org.gradle.nativeplatform.fixtures.app.MainWithXCTestSourceElement.java
@Override public List<SourceFile> getFiles() { return Lists.newArrayList(Iterables.concat(getMain().getFiles(), getTest().getFiles())); }
From source file:com.facebook.buck.cxx.OmnibusRootNode.java
@Override public Iterable<? extends NativeLinkable> getNativeLinkTargetDeps(CxxPlatform cxxPlatform) { return Iterables.concat(getNativeLinkableDepsForPlatform(cxxPlatform), getNativeLinkableExportedDepsForPlatform(cxxPlatform)); }
From source file:com.wrmsr.nativity.x86.DisImpl.java
public static ByteTrie<Entry> buildTrie(Iterable<Entry> entries) { ByteTrie<Entry> trie = new ByteTrie<>(); for (Entry entry : entries) { for (Ref.Syntax syntax : entry.getSyntaxes()) { byte[] bytes = toByteArray(entry.getBytes()); if (entry.getPrefixByte() != null) { bytes = ArrayUtils.addAll(new byte[] { entry.getPrefixByte() }, bytes); }// w w w . java 2s . c o m if (entry.getSecondaryByte() != null) { bytes = ArrayUtils.addAll(bytes, new byte[] { entry.getSecondaryByte() }); } trie.add(bytes, entry); Ref.Operand zOperand = null; for (Ref.Operand operand : Iterables.concat(syntax.getDstOperands(), syntax.getSrcOperands())) { if (operand.address == Ref.Operand.Address.Z) { if (zOperand != null) { throw new IllegalStateException(); } zOperand = operand; break; } } if (zOperand == null) { continue; } bytes = toByteArray(entry.getBytes()); if ((bytes[bytes.length - 1] & (byte) 7) != (byte) 0) { throw new IllegalStateException(); } for (byte i = 1; i < 8; ++i) { bytes = toByteArray(entry.getBytes()); bytes[bytes.length - 1] |= i; if (entry.getPrefixByte() != null) { bytes = ArrayUtils.addAll(new byte[] { entry.getPrefixByte() }, bytes); } if (entry.getSecondaryByte() != null) { bytes = ArrayUtils.addAll(bytes, new byte[] { entry.getSecondaryByte() }); } trie.add(bytes, entry); } } } return trie; }
From source file:fr.javatronic.damapping.test.injectable.service.HotelService.java
public List<Room> getRooms() { return ImmutableList .copyOf(Iterables.concat(hotel.getFloors().get(0).getRooms(), hotel.getFloors().get(1).getRooms())); }
From source file:com.altoukhov.svsync.engines.Syncer.java
public static void sync(SourceInfo sourceInfo, TargetInfo targetInfo) { Analyzer analyzer = new Analyzer(sourceInfo, targetInfo); if (!analyzer.init()) { System.out.println("Analyzer failed to init"); return;//from w w w . ja v a 2 s . c om } Diff diff = analyzer.analyze(); System.out.println("Diff for " + sourceInfo.getName()); System.out.println(diff.toString()); IReadableFileSpace source = analyzer.getSource(); IWriteableFileSpace target = analyzer.getTarget(); IWriteableFileSpace cache = analyzer.getCache(); System.out.println("Syncing " + sourceInfo.getName()); // Create added directories List<String> addedDirectories = new ArrayList<>(diff.getDirectoryChanges(Diff.DiffType.ADDED)); Collections.sort(addedDirectories); for (String dir : addedDirectories) { System.out.println("Creating directory " + dir); target.createDirectory(dir); cache.createDirectory(dir); } // Add + update files for (FileSnapshot file : Iterables.concat(diff.getFileChanges(Diff.DiffType.ADDED), diff.getFileChanges(Diff.DiffType.CHANGED))) { writeFile(source, target, file); cache.writeFile(null, file); } // Delete files for (FileSnapshot file : diff.getFileChanges(Diff.DiffType.DELETED)) { System.out.println("Deleting file " + file.getRelativePath()); target.deleteFile(file.getRelativePath()); cache.deleteFile(file.getRelativePath()); } // Move files for (FileSnapshot file : diff.getFileChanges(Diff.DiffType.MOVED)) { System.out.println("Moving file from " + file.getPreviousPath() + " to " + file.getRelativePath()); target.moveFile(file.getPreviousPath(), file.getRelativePath()); cache.moveFile(file.getPreviousPath(), file.getRelativePath()); } // Delete removed directories (should be empty by this point) List<String> deletedDirectories = new ArrayList<>(diff.getDirectoryChanges(Diff.DiffType.DELETED)); Collections.sort(deletedDirectories, Collections.reverseOrder()); for (String dir : deletedDirectories) { System.out.println("Deleting directory " + dir); target.deleteDirectory(dir); cache.deleteDirectory(dir); } analyzer.updateCache(); }
From source file:com.palantir.common.collect.IterableUtils.java
public static <T> Iterable<T> append(Iterable<? extends T> a, T b) { Preconditions.checkNotNull(a);/* www . j a v a 2 s.com*/ return Iterables.concat(a, Collections.singleton(b)); }
From source file:forge.download.GuiDownloadSetPicturesLQ.java
@Override protected final Map<String, String> getNeededFiles() { final Map<String, String> downloads = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); for (final PaperCard c : Iterables.concat(FModel.getMagicDb().getCommonCards().getAllCards(), FModel.getMagicDb().getVariantCards().getAllCards())) { final String setCode3 = c.getEdition(); if (StringUtils.isBlank(setCode3) || CardEdition.UNKNOWN.getCode().equals(setCode3)) { // we don't want cards from unknown sets continue; }/*from w w w . ja v a 2 s . c o m*/ addDLObject(ImageUtil.getDownloadUrl(c, false), ImageUtil.getImageKey(c, false, true), downloads); if (ImageUtil.hasBackFacePicture(c)) { addDLObject(ImageUtil.getDownloadUrl(c, true), ImageUtil.getImageKey(c, true, true), downloads); } } // Add missing tokens to the list of things to download. addMissingItems(downloads, ForgeConstants.IMAGE_LIST_TOKENS_FILE, ForgeConstants.CACHE_TOKEN_PICS_DIR); return downloads; }