List of usage examples for com.google.common.collect Iterables getLast
public static <T> T getLast(Iterable<T> iterable)
From source file:it.unibz.inf.ontop.protege.utils.CustomTraversalPolicy.java
public Component getLastComponent(Container focusCycleRoot) { return Iterables.getLast(order); }
From source file:com.urswolfer.intellij.plugin.gerrit.SelectedRevisions.java
/** * @return the selected revision for the provided change info object *//*from w w w . j a v a 2 s. co m*/ public String get(ChangeInfo changeInfo) { String currentRevision = changeInfo.currentRevision; if (currentRevision == null && changeInfo.revisions != null) { // don't know why with some changes currentRevision is not set, // the revisions map however is usually populated currentRevision = Iterables.getLast(changeInfo.revisions.keySet()); } assert currentRevision != null; return get(changeInfo.changeId).or(currentRevision); }
From source file:com.google.security.zynamics.reil.algorithms.mono.InstructionGraph.java
/** * Creates an instruction graph from a REIL graph. * /* w w w. j a v a2 s. c om*/ * @param graph The REIL graph to convert. * * @return The created instruction graph. */ public static InstructionGraph create(final ReilGraph graph) { Preconditions.checkNotNull(graph, "Error: graph argument can not be null"); final List<InstructionGraphNode> nodes = new ArrayList<InstructionGraphNode>(); final List<InstructionGraphEdge> edges = new ArrayList<InstructionGraphEdge>(); final HashMap<ReilBlock, InstructionGraphNode> firstNodeMapping = new HashMap<ReilBlock, InstructionGraphNode>(); final HashMap<ReilBlock, InstructionGraphNode> lastNodeMapping = new HashMap<ReilBlock, InstructionGraphNode>(); for (final ReilBlock block : graph) { InstructionGraphNode lastNode = null; final ReilInstruction lastInstruction = Iterables.getLast(block.getInstructions()); for (final ReilInstruction instruction : block) { final InstructionGraphNode currentNode = new InstructionGraphNode(instruction); // NOPMD by // sp on // 04.11.08 // 14:17 nodes.add(currentNode); if (instruction == lastInstruction) { lastNodeMapping.put(block, currentNode); } if (!firstNodeMapping.containsKey(block)) { firstNodeMapping.put(block, currentNode); } if (lastNode != null) { final InstructionGraphEdge edge = new InstructionGraphEdge(lastNode, currentNode, EdgeType.JUMP_UNCONDITIONAL); // NOPMD // by sp // on // 04.11.08 // 14:18 edges.add(edge); InstructionGraphNode.link(lastNode, currentNode, edge); } lastNode = currentNode; } } for (final ReilBlock block : graph) { for (final ReilEdge edge : block.getOutgoingEdges()) { final InstructionGraphEdge newEdge = new InstructionGraphEdge(lastNodeMapping.get(block), firstNodeMapping.get(edge.getTarget()), edge.getType()); // NOPMD by sp on 04.11.08 14:18 edges.add(newEdge); InstructionGraphNode.link(lastNodeMapping.get(block), firstNodeMapping.get(edge.getTarget()), newEdge); } } return new InstructionGraph(nodes, edges); }
From source file:io.soliton.protobuf.plugin.ProtoFileHandler.java
@VisibleForTesting static String inferOuterClassName(FileDescriptorProto file) { String fileName = file.getName(); if (fileName.endsWith(".proto")) { fileName = fileName.substring(0, fileName.length() - ".proto".length()); }/*from w ww.ja va 2 s.co m*/ fileName = Iterables.getLast(Splitter.on('/').split(fileName)); fileName = fileName.replace('-', '_'); fileName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, fileName); return Character.toUpperCase(fileName.charAt(0)) + fileName.substring(1); }
From source file:org.apache.flink.streaming.api.windowing.evictors.TimeEvictor.java
@Override public int evict(Iterable<StreamRecord<Object>> elements, int size, W window) { int toEvict = 0; long currentTime = Iterables.getLast(elements).getTimestamp(); long evictCutoff = currentTime - windowSize; for (StreamRecord<Object> record : elements) { if (record.getTimestamp() > evictCutoff) { break; }// w w w .ja va 2 s . c o m toEvict++; } return toEvict; }
From source file:org.apache.metron.dataloads.extractor.csv.CSVExtractor.java
private static Map.Entry<String, Integer> getColumnMapEntry(String column, int i) { if (column.contains(":")) { Iterable<String> tokens = Splitter.on(':').split(column); String col = Iterables.getFirst(tokens, null); Integer pos = Integer.parseInt(Iterables.getLast(tokens)); return new AbstractMap.SimpleEntry<>(col, pos); } else {/*from w ww . ja v a 2 s . co m*/ return new AbstractMap.SimpleEntry<>(column, i); } }
From source file:dmh.swing.CustomFocusTraversalPolicy.java
@Override public Component getLastComponent(Container focusCycleRoot) { return Iterables.getLast(components); }
From source file:jflowmap.es_agg.SegmentedEdge.java
/** * Adds {@code segment} to the edge. The {@code segment} must be * consecutive to the last segment of the edge (its start point * must be the same as the end point of the last segment of the edge). * * @throws IllegalArgumentException If the segment is not consecutive * to the last segment of the edge.//from w w w. ja v a 2s . co m */ public void addConsecutiveSegment(EdgeSegment segment) { if (segments.size() > 0) { if (!segment.isConsecutiveFor(Iterables.getLast(segments))) { throw new IllegalArgumentException("Segments are not consecutive"); } } // System.out.println("Add segment " + System.identityHashCode(segment) + " to edge " + System.identityHashCode(this)); // if (!segment.getParents().contains(this)) { // throw new IllegalArgumentException(); // } segments.add(segment); segment.addParent(this); }
From source file:is.illuminati.block.spyros.garmin.model.Lap.java
/** * Get End time of the lap */ public DateTime getEndTime() { Track lastTrack = Iterables.getLast(tracks); return lastTrack.getEndTime(); }
From source file:org.eclipse.tracecompasss.statesystem.core.tests.stubs.backend.HistoryTreeStub.java
/** * Get the latest leaf of the tree//from w ww. j ava2 s.com * * @return The current leaf node of the tree */ public HTNode getLatestLeaf() { List<HTNode> latest = getLatestBranch(); return checkNotNull(Iterables.getLast(latest)); }