Java 类org.apache.commons.lang3.tuple.MutablePair 实例源码

项目:Catan    文件:SessionScreen.java   
private void getValidEdgePosition() {
    // loops through valid road end points and adds valid edges (both ships and roads)
    for (CoordinatePair i : aSessionController.requestValidRoadEndpoints(aSessionController.getPlayerColor())) {
        for (CoordinatePair j : aSessionController.getIntersectionsAndEdges()) {
            if (aSessionController.isAdjacent(i, j)) {

                Pair<CoordinatePair, CoordinatePair> edge = new MutablePair<>(i, j);
                validEdges.add(edge);

                for (EdgeUnit eu : aSessionController.getRoadsAndShips()) {
                    if (eu.hasEndpoint(i) && eu.hasEndpoint(j)) {
                        validEdges.remove(edge);
                    }
                }
            }
        }
    }
}
项目:Catan    文件:ProgressCardHandler.java   
void updateValidEdges(List<Pair<CoordinatePair,CoordinatePair>> validEdges) {
 // loops through valid road end points and adds valid edges (both ships and roads)
    for (CoordinatePair i : aSessionController.requestValidRoadEndpoints(aSessionController.getPlayerColor())) {
        for (CoordinatePair j : aSessionController.getIntersectionsAndEdges()) { 
            if (aSessionController.isAdjacent(i, j)) {

                Pair<CoordinatePair, CoordinatePair> edge = new MutablePair<>(i, j);
                validEdges.add(edge);

                for (EdgeUnit eu : aSessionController.getRoadsAndShips()) {
                    if (eu.hasEndpoint(i) && eu.hasEndpoint(j)) {
                        validEdges.remove(edge);
                    }
                }
            }
        } 
    }
}
项目:SamaGamesAPI    文件:TeamSpeakAPI.java   
public static int createChannel(@Nonnull String name, @Nullable Map<ChannelProperty, String> channelProperties, @Nullable Map<ChannelPermission, Integer> permissions)
{
    MutablePair<ResultType, Object> pair = MutablePair.of(ResultType.INTEGER, -1);
    int id = generator++;
    TeamSpeakAPI.results.put(id, pair);
    final String[] msg = {"createchannel:" + name};
    if (channelProperties != null)
        channelProperties.forEach(((channelProperty, s) -> msg[0] += ":" + channelProperties.toString().toUpperCase() + "=" + s));
    if (permissions != null)
        permissions.forEach(((channelPermission, integer) -> msg[0] += ":" + channelPermission.toString().toLowerCase() + "-" + integer));
    TeamSpeakAPI.publish(id, msg[0]);
    try
    {
        synchronized (pair)
        {
            pair.wait(TeamSpeakAPI.TIMEOUT);
        }
    } catch (Exception ignored) {}
    return (int)pair.getRight();
}
项目:SamaGamesAPI    文件:TeamSpeakAPI.java   
public static List<UUID> movePlayers(@Nonnull List<UUID> uuids, int channelId)
{
    MutablePair<ResultType, Object> pair = MutablePair.of(ResultType.UUID_LIST, new ArrayList<>());
    int id = generator++;
    TeamSpeakAPI.results.put(id, pair);
    final String[] msg = {"move:" + channelId};
    uuids.forEach(uuid -> msg[0] += ":" + uuid);
    TeamSpeakAPI.publish(id, msg[0]);
    try
    {
        synchronized (pair)
        {
            pair.wait(TeamSpeakAPI.TIMEOUT);
        }
    } catch (Exception ignored) {}
    return (List<UUID>) pair.getRight();
}
项目:doctorkafka    文件:OperatorUtil.java   
public static MutablePair<Long, Long> getProcNetDevStats() throws Exception {
  ProcessBuilder ps = new ProcessBuilder("cat", "/proc/net/dev");
  Process pr = ps.start();
  pr.waitFor();

  BufferedReader in = new BufferedReader(new InputStreamReader(pr.getInputStream()));
  String line;
  int counter = 0;
  long receivedBytes = 0;
  long outBytes = 0;

  while ((line = in.readLine()) != null) {
    System.out.println(counter + ": " + line);
    if (line.contains("eth0")) {
      String[] strs = line.split(" ");
      receivedBytes = Long.parseLong(strs[3]);
      outBytes = Long.parseLong(strs[41]);
      System.out.println(" inBytes = " + receivedBytes + "  outBytes = " + outBytes);
    }
    counter++;
  }
  in.close();

  MutablePair<Long, Long> result = new MutablePair<>(receivedBytes, outBytes);
  return result;
}
项目:diorite-configs-java8    文件:CommentsNodeImpl.java   
public Map<String, MutablePair<String, CommentsNodeImpl>> copyMap(CommentsNodeImpl parent)
{
    Map<String, MutablePair<String, CommentsNodeImpl>> result = new HashMap<>(this.dataMap.size());
    for (Entry<String, MutablePair<String, CommentsNodeImpl>> entry : this.dataMap.entrySet())
    {
        String keyToCpy = entry.getKey();
        MutablePair<String, CommentsNodeImpl> valueToCpy = entry.getValue();
        CommentsNodeImpl nodeToCpy = valueToCpy.getRight();
        CommentsNodeImpl copiedNode;
        if (nodeToCpy == null)
        {
            copiedNode = null;
        }
        else
        {
            copiedNode = new CommentsNodeImpl(parent);
            copiedNode.dataMap.putAll(nodeToCpy.copyMap(parent));
        }
        MutablePair<String, CommentsNodeImpl> copied = new MutablePair<>(valueToCpy.getLeft(), copiedNode);
        result.put(keyToCpy, copied);
    }
    return result;
}
项目:diorite-configs-java8    文件:CommentsNodeImpl.java   
@Override
public void trim()
{
    for (Iterator<Entry<String, MutablePair<String, CommentsNodeImpl>>> iterator = this.dataMap.entrySet().iterator(); iterator.hasNext(); )
    {
        Entry<String, MutablePair<String, CommentsNodeImpl>> entry = iterator.next();
        MutablePair<String, CommentsNodeImpl> value = entry.getValue();
        CommentsNodeImpl right = value.getRight();
        if (right != null)
        {
            right.trim();
        }
        if (((right == null) || right.dataMap.isEmpty()) && (value.getLeft() == null))
        {
            iterator.remove();
            continue;
        }
        if (right == null)
        {
            continue;
        }
        right.trim();
    }
}
项目:diorite-configs-java8    文件:CommentsNodeImpl.java   
@Override
@Nullable
public String getComment(String path)
{
    MutablePair<String, CommentsNodeImpl> nodePair = this.dataMap.get(path);
    if (nodePair != null)
    {
        String comment = nodePair.getLeft();
        if (comment != null)
        {
            return comment;
        }
    }
    MutablePair<String, CommentsNodeImpl> anyNodePair = this.dataMap.get(ANY);
    if (anyNodePair != null)
    {
        return anyNodePair.getKey();
    }
    return null;
}
项目:diorite-configs-java8    文件:CommentsNodeImpl.java   
@Override
public CommentsNodeImpl getNode(String path)
{
    MutablePair<String, CommentsNodeImpl> nodePair = this.dataMap.get(path);
    CommentsNodeImpl node = (nodePair == null) ? null : nodePair.getRight();
    if (node == null)
    {
        MutablePair<String, CommentsNodeImpl> anyNodePair = this.dataMap.get(ANY);
        node = (anyNodePair == null) ? null : anyNodePair.getRight();
        if (node == null)
        {
            CommentsNodeImpl commentsNode = new CommentsNodeImpl(this);
            if (nodePair != null)
            {
                nodePair.setRight(commentsNode);
            }
            else
            {
                this.dataMap.put(path, new MutablePair<>(null, commentsNode));
            }
            return commentsNode;
        }
        return node;
    }
    return node;
}
项目:yauaa    文件:ParseService.java   
private Pair<String, String> prefixSplitter(String input) {
    MutablePair<String, String> result = new MutablePair<>("", input);
    if (input.startsWith("Device")) {
        result.setLeft("Device");
        result.setRight(input.replaceFirst("Device", ""));
    } else if (input.startsWith("OperatingSystem")) {
        result.setLeft("Operating System");
        result.setRight(input.replaceFirst("OperatingSystem", ""));
    } else if (input.startsWith("LayoutEngine")) {
        result.setLeft("Layout Engine");
        result.setRight(input.replaceFirst("LayoutEngine", ""));
    } else if (input.startsWith("Agent")) {
        result.setLeft("Agent");
        result.setRight(input.replaceFirst("Agent", ""));
    }
    return result;
}
项目:apex-core    文件:ResourceRequestHandler.java   
/**
 * Issue requests to AM RM Client again if previous container requests expired and were not allocated by Yarn
 * @param amRmClient
 * @param requestedResources
 * @param loopCounter
 * @param resourceRequestor
 * @param containerRequests
 * @param removedContainerRequests
 */
public void reissueContainerRequests(AMRMClient<ContainerRequest> amRmClient, Map<StreamingContainerAgent.ContainerStartRequest, MutablePair<Integer, ContainerRequest>> requestedResources, int loopCounter, ResourceRequestHandler resourceRequestor, List<ContainerRequest> containerRequests, List<ContainerRequest> removedContainerRequests)
{
  if (!requestedResources.isEmpty()) {
    for (Map.Entry<StreamingContainerAgent.ContainerStartRequest, MutablePair<Integer, ContainerRequest>> entry : requestedResources.entrySet()) {
      /*
       * Create container requests again if pending requests were not allocated by Yarn till timeout.
       */
      if ((loopCounter - entry.getValue().getKey()) > NUMBER_MISSED_HEARTBEATS) {
        StreamingContainerAgent.ContainerStartRequest csr = entry.getKey();
        LOG.debug("Request for container {} timed out. Re-requesting container", csr.container);
        removedContainerRequests.add(entry.getValue().getRight());
        ContainerRequest cr = resourceRequestor.createContainerRequest(csr, false);
        entry.getValue().setLeft(loopCounter);
        entry.getValue().setRight(cr);
        containerRequests.add(cr);
      }
    }
  }
}
项目:apex-malhar    文件:AbstractKinesisInputOperator.java   
/**
 * Implement InputOperator Interface.
 */
@Override
public void emitTuples()
{
  if (currentWindowId <= windowDataManager.getLargestCompletedWindow()) {
    return;
  }
  int count = consumer.getQueueSize();
  if (maxTuplesPerWindow > 0) {
    count = Math.min(count, maxTuplesPerWindow - emitCount);
  }
  for (int i = 0; i < count; i++) {
    Pair<String, Record> data = consumer.pollRecord();
    String shardId = data.getFirst();
    String recordId = data.getSecond().getSequenceNumber();
    emitTuple(data);
    MutablePair<String, Integer> shardOffsetAndCount = currentWindowRecoveryState.get(shardId);
    if (shardOffsetAndCount == null) {
      currentWindowRecoveryState.put(shardId, new MutablePair<String, Integer>(recordId, 1));
    } else {
      shardOffsetAndCount.setRight(shardOffsetAndCount.right + 1);
    }
    shardPosition.put(shardId, recordId);
  }
  emitCount += count;
}
项目:apex-malhar    文件:LogstreamWidgetOutputOperator.java   
private void processTopN(HashMap<String, Number> topNMap, HashMap<String, Object> schemaObj)
{
  @SuppressWarnings("unchecked")
  HashMap<String, Object>[] result = (HashMap<String, Object>[])Array.newInstance(HashMap.class, topNMap.size());

  int j = 0;
  for (Entry<String, Number> e : topNMap.entrySet()) {
    result[j] = new HashMap<String, Object>();
    result[j].put("name", e.getKey());
    String val = formatter.format(e.getValue());
    result[j++].put("value", val);
  }
  if (operator.isWebSocketConnected) {
    schemaObj.put("type", "topN");
    schemaObj.put("n", operator.nInTopN);
    operator.wsoo.input.process(new MutablePair<String, Object>(operator.getFullTopic(operator.topNTopic, schemaObj), result));
  }
  else {
    operator.coo.input.process(topNMap);
  }

}
项目:apex-malhar    文件:WidgetOutputOperator.java   
@Override
public void process(TimeSeriesData[] tuple)
{
  @SuppressWarnings({"unchecked", "rawtypes"})
  HashMap<String, Number>[] timeseriesMapData = new HashMap[tuple.length];
  int i = 0;
  for (TimeSeriesData data : tuple) {
    HashMap<String, Number> timeseriesMap = Maps.newHashMapWithExpectedSize(2);
    timeseriesMap.put("timestamp", data.time);
    timeseriesMap.put("value", data.data);
    timeseriesMapData[i++] = timeseriesMap;
  }

  if (operator.isWebSocketConnected) {
    HashMap<String, Object> schemaObj = new HashMap<>();
    schemaObj.put("type", "timeseries");
    schemaObj.put("minValue", operator.timeSeriesMin);
    schemaObj.put("maxValue", operator.timeSeriesMax);
    operator.wsoo.input.process(new MutablePair<String, Object>(operator.getFullTopic( operator.timeSeriesTopic, schemaObj), timeseriesMapData));
  } else {
    operator.coo.input.process(tuple);
  }
}
项目:apex-malhar    文件:WidgetOutputOperator.java   
@Override
public void process(HashMap<String, Number> topNMap)
{
  @SuppressWarnings({"unchecked", "rawtypes"})
  HashMap<String, Object>[] result = new HashMap[topNMap.size()];
  int j = 0;
  for (Entry<String, Number> e : topNMap.entrySet()) {
    result[j] = new HashMap<>();
    result[j].put("name", e.getKey());
    result[j++].put("value", e.getValue());
  }
  if (operator.isWebSocketConnected) {
    HashMap<String, Object> schemaObj = new HashMap<>();
    schemaObj.put("type", "topN");
    schemaObj.put("n", operator.nInTopN);
    operator.wsoo.input.process(new MutablePair<String, Object>(operator.getFullTopic(operator.topNTopic, schemaObj), result));
  } else {
    operator.coo.input.process(topNMap);
  }
}
项目:apex-malhar    文件:WidgetOutputOperator.java   
@Override
public void process(HashMap<String, Number> pieNumbers)
{
  @SuppressWarnings("unchecked")
  HashMap<String, Object>[] result = (HashMap<String, Object>[])Array.newInstance(HashMap.class, pieNumbers.size());

  int j = 0;
  for (Entry<String, Number> e : pieNumbers.entrySet()) {
    result[j] = new HashMap<>();
    result[j].put("label", e.getKey());
    result[j++].put("value", e.getValue());
  }
  if (operator.isWebSocketConnected) {
    HashMap<String, Object> schemaObj = new HashMap<>();
    schemaObj.put("type", "piechart");
    schemaObj.put("n", operator.nInPie);
    operator.wsoo.input.process(new MutablePair<String, Object>(operator.getFullTopic(operator.pieChartTopic, schemaObj), result));
  } else {
    operator.coo.input.process(pieNumbers);
  }
}
项目:apex-malhar    文件:Application.java   
@Override
public void populateDAG(DAG dag, Configuration configuration)
{
  RandomNumberPairGenerator inputOperator = new RandomNumberPairGenerator();
  WindowedOperatorImpl<MutablePair<Double, Double>, MutablePair<MutableLong, MutableLong>, Double> windowedOperator = new WindowedOperatorImpl<>();
  Accumulation<MutablePair<Double, Double>, MutablePair<MutableLong, MutableLong>, Double> piAccumulation = new PiAccumulation();

  windowedOperator.setAccumulation(piAccumulation);
  windowedOperator.setDataStorage(new InMemoryWindowedStorage<MutablePair<MutableLong, MutableLong>>());
  windowedOperator.setWindowStateStorage(new InMemoryWindowedStorage<WindowState>());
  windowedOperator.setWindowOption(new WindowOption.GlobalWindow());
  windowedOperator.setTriggerOption(TriggerOption.AtWatermark().withEarlyFiringsAtEvery(Duration.millis(1000)).accumulatingFiredPanes());

  ConsoleOutputOperator outputOperator = new ConsoleOutputOperator();
  dag.addOperator("inputOperator", inputOperator);
  dag.addOperator("windowedOperator", windowedOperator);
  dag.addOperator("outputOperator", outputOperator);
  dag.addStream("input_windowed", inputOperator.output, windowedOperator.input);
  dag.addStream("windowed_output", windowedOperator.output, outputOperator.input);
}
项目:Diorite    文件:CommentsNodeImpl.java   
public Map<String, MutablePair<String, CommentsNodeImpl>> copyMap(CommentsNodeImpl parent)
{
    Map<String, MutablePair<String, CommentsNodeImpl>> result = new HashMap<>(this.dataMap.size());
    for (Entry<String, MutablePair<String, CommentsNodeImpl>> entry : this.dataMap.entrySet())
    {
        String keyToCpy = entry.getKey();
        MutablePair<String, CommentsNodeImpl> valueToCpy = entry.getValue();
        CommentsNodeImpl nodeToCpy = valueToCpy.getRight();
        CommentsNodeImpl copiedNode;
        if (nodeToCpy == null)
        {
            copiedNode = null;
        }
        else
        {
            copiedNode = new CommentsNodeImpl(parent);
            copiedNode.dataMap.putAll(nodeToCpy.copyMap(parent));
        }
        MutablePair<String, CommentsNodeImpl> copied = new MutablePair<>(valueToCpy.getLeft(), copiedNode);
        result.put(keyToCpy, copied);
    }
    return result;
}
项目:Diorite    文件:CommentsNodeImpl.java   
@Override
public void trim()
{
    for (Iterator<Entry<String, MutablePair<String, CommentsNodeImpl>>> iterator = this.dataMap.entrySet().iterator(); iterator.hasNext(); )
    {
        Entry<String, MutablePair<String, CommentsNodeImpl>> entry = iterator.next();
        MutablePair<String, CommentsNodeImpl> value = entry.getValue();
        CommentsNodeImpl right = value.getRight();
        if (right != null)
        {
            right.trim();
        }
        if (((right == null) || right.dataMap.isEmpty()) && (value.getLeft() == null))
        {
            iterator.remove();
            continue;
        }
        if (right == null)
        {
            continue;
        }
        right.trim();
    }
}
项目:Diorite    文件:CommentsNodeImpl.java   
@Override
@Nullable
public String getComment(String path)
{
    MutablePair<String, CommentsNodeImpl> nodePair = this.dataMap.get(path);
    if (nodePair != null)
    {
        String comment = nodePair.getLeft();
        if (comment != null)
        {
            return comment;
        }
    }
    MutablePair<String, CommentsNodeImpl> anyNodePair = this.dataMap.get(ANY);
    if (anyNodePair != null)
    {
        return anyNodePair.getKey();
    }
    return null;
}
项目:Diorite    文件:CommentsNodeImpl.java   
@Override
public CommentsNodeImpl getNode(String path)
{
    MutablePair<String, CommentsNodeImpl> nodePair = this.dataMap.get(path);
    CommentsNodeImpl node = (nodePair == null) ? null : nodePair.getRight();
    if (node == null)
    {
        MutablePair<String, CommentsNodeImpl> anyNodePair = this.dataMap.get(ANY);
        node = (anyNodePair == null) ? null : anyNodePair.getRight();
        if (node == null)
        {
            CommentsNodeImpl commentsNode = new CommentsNodeImpl(this);
            if (nodePair != null)
            {
                nodePair.setRight(commentsNode);
            }
            else
            {
                this.dataMap.put(path, new MutablePair<>(null, commentsNode));
            }
            return commentsNode;
        }
        return node;
    }
    return node;
}
项目:morecommands    文件:MergedMappedSettings.java   
/**
 * Invoked when a mapping of a map of one of the settings is removed.<br>
 * This is used to adjust the merged map accordingly
 * 
 * @param sc the setting of which the entry was removed
 * @param key the key of the mapping to be removed
 */
private synchronized void onRemove(SettingsContainer sc, Object key) {
    MutablePair<V, Integer> pair = this.mergedMap.get(key);

    if (pair != null && pair.getRight() == sc.listIndex) {
        Pair<V, Integer> newVal = getIndexAndValueForKey(key);

        if (newVal != null) {
            pair.setLeft(newVal.getLeft());
            pair.setRight(newVal.getRight());
        }
        else this.mergedMap.remove(key);
    }

    removeMapIfEmpty(sc.listIndex);
}
项目:gatk-protected    文件:SharedVertexSequenceSplitter.java   
/**
 * Return the longest suffix of bases shared among all provided vertices
 *
 * For example, if the vertices have sequences AC, CC, and ATC, this would return
 * a single C.  However, for ACC and TCC this would return CC.  And for AC and TG this
 * would return null;
 *
 * @param middleVertices a non-empty set of vertices
 * @return
 */
@VisibleForTesting
static Pair<SeqVertex, SeqVertex> commonPrefixAndSuffixOfVertices(final Collection<SeqVertex> middleVertices) {
    final List<byte[]> kmers = new ArrayList<>(middleVertices.size());

    int min = Integer.MAX_VALUE;
    for ( final SeqVertex v : middleVertices ) {
        kmers.add(v.getSequence());
        min = Math.min(min, v.getSequence().length);
    }

    final int prefixLen = GraphUtils.commonMaximumPrefixLength(kmers);
    final int suffixLen = GraphUtils.commonMaximumSuffixLength(kmers, min - prefixLen);

    final byte[] kmer = kmers.get(0);
    final byte[] prefix = Arrays.copyOfRange(kmer, 0, prefixLen);
    final byte[] suffix = Arrays.copyOfRange(kmer, kmer.length - suffixLen, kmer.length);
    return new MutablePair<>(new SeqVertex(prefix), new SeqVertex(suffix));
}
项目:gatk    文件:GATKVariantContextUtils.java   
public static Pair<int[],byte[]> getNumTandemRepeatUnits(final byte[] refBases, final byte[] altBases, final byte[] remainingRefContext) {
     /* we can't exactly apply same logic as in basesAreRepeated() to compute tandem unit and number of repeated units.
       Consider case where ref =ATATAT and we have an insertion of ATAT. Natural description is (AT)3 -> (AT)2.
     */

    byte[] longB;
    // find first repeat unit based on either ref or alt, whichever is longer
    if (altBases.length > refBases.length)
        longB = altBases;
    else
        longB = refBases;

    // see if non-null allele (either ref or alt, whichever is longer) can be decomposed into several identical tandem units
    // for example, -*,CACA needs to first be decomposed into (CA)2
    final int repeatUnitLength = findRepeatedSubstring(longB);
    final byte[] repeatUnit = Arrays.copyOf(longB, repeatUnitLength);

    final int[] repetitionCount = new int[2];
    // look for repetitions forward on the ref bases (i.e. starting at beginning of ref bases)
    int repetitionsInRef = findNumberOfRepetitions(repeatUnit, refBases, true);
    repetitionCount[0] = findNumberOfRepetitions(repeatUnit, ArrayUtils.addAll(refBases, remainingRefContext), true)-repetitionsInRef;
    repetitionCount[1] = findNumberOfRepetitions(repeatUnit, ArrayUtils.addAll(altBases, remainingRefContext), true)-repetitionsInRef;

    return new MutablePair<>(repetitionCount, repeatUnit);

}
项目:gatk    文件:SharedVertexSequenceSplitter.java   
/**
 * Return the longest suffix of bases shared among all provided vertices
 *
 * For example, if the vertices have sequences AC, CC, and ATC, this would return
 * a single C.  However, for ACC and TCC this would return CC.  And for AC and TG this
 * would return null;
 *
 * @param middleVertices a non-empty set of vertices
 * @return
 */
@VisibleForTesting
static Pair<SeqVertex, SeqVertex> commonPrefixAndSuffixOfVertices(final Collection<SeqVertex> middleVertices) {
    final List<byte[]> kmers = new ArrayList<>(middleVertices.size());

    int min = Integer.MAX_VALUE;
    for ( final SeqVertex v : middleVertices ) {
        kmers.add(v.getSequence());
        min = Math.min(min, v.getSequence().length);
    }

    final int prefixLen = GraphUtils.commonMaximumPrefixLength(kmers);
    final int suffixLen = GraphUtils.commonMaximumSuffixLength(kmers, min - prefixLen);

    final byte[] kmer = kmers.get(0);
    final byte[] prefix = Arrays.copyOfRange(kmer, 0, prefixLen);
    final byte[] suffix = Arrays.copyOfRange(kmer, kmer.length - suffixLen, kmer.length);
    return new MutablePair<>(new SeqVertex(prefix), new SeqVertex(suffix));
}
项目:cloud-slang    文件:CachedPrecompileServiceImplTest.java   
@Test
public void testCacheValueSuccess() {
    String myPath = "aaa";
    ExecutableModellingResult executableModellingResult = mock(ExecutableModellingResult.class);
    SlangSource slangSource = mock(SlangSource.class);

    final MutablePair<CacheValue, Boolean> pair = new MutablePair<>();
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            pair.setLeft((CacheValue) invocation.getArguments()[1]);
            return null;
        }
    }).when(cache).put(anyString(), any(CacheValue.class));

    // Tested call
    cachedPrecompileServiceImpl.cacheValue(myPath, executableModellingResult, slangSource);
    verify(cache).put(eq(myPath), same(pair.getLeft()));
}
项目:cloud-slang    文件:CachedPrecompileServiceImplTest.java   
@Test
public void testCacheValueDoesNothingForNull() {
    String myPath = null;
    ExecutableModellingResult executableModellingResult = mock(ExecutableModellingResult.class);
    SlangSource slangSource = mock(SlangSource.class);

    final MutablePair<CacheValue, Boolean> pair = new MutablePair<>();
    doAnswer(new Answer() {
        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            pair.setLeft((CacheValue) invocation.getArguments()[1]);
            return null;
        }
    }).when(cache).put(anyString(), any(CacheValue.class));

    // Tested call
    cachedPrecompileServiceImpl.cacheValue(myPath, executableModellingResult, slangSource);
    verify(cache, never()).put(anyString(), any(CacheValue.class));
}
项目:JLoopix    文件:SphinxClient.java   
public static Pair<SphinxHeader, byte[]> packageSurb(SphinxParams params,
                                                     SphinxSingleUseReplyBlock nymTuple,
                                                     byte[] message) throws SphinxException, CryptoException {
    byte[] body = params.pi(
            nymTuple.ktilde,
            padBody(
                    params.m,
                    Arrays.concatenate(
                            new byte[params.k],
                            message
                    )
            )
    );
    return new MutablePair<>(nymTuple.header, body);
}
项目:JLoopix    文件:SphinxClient.java   
public static Pair<SphinxParams, Pair<SphinxHeader, byte[]>> unpackMessage(List<SphinxParams> params, byte[] m) throws IOException {
    Unpacker unpacker = Unpacker.getUnpacker(m);
    unpacker.unpackArrayHeader();
    unpacker.unpackArrayHeader();
    int paramsMaxLength = unpacker.unpackInt();
    int paramsM = unpacker.unpackInt();
    unpacker.unpackArrayHeader();
    unpacker.unpackArrayHeader();
    ECPoint alpha = unpacker.unpackEcPoint();
    byte[] beta = unpacker.readPayload(unpacker.unpackBinaryHeader());
    byte[] gamma = unpacker.readPayload(unpacker.unpackBinaryHeader());

    SphinxHeader header = new SphinxHeader(alpha, beta, gamma);

    byte[] message = unpacker.readPayload(unpacker.unpackBinaryHeader());

    SphinxParams msgParams = null;
    for (SphinxParams param : params) {
        if (paramsMaxLength == param.maxLength &&
                paramsM == param.m) {
            msgParams = param;
            break;
        }
    }
    if (msgParams == null) {
        throw new RuntimeException("No parameter settings.");
    }
    return new MutablePair<>(msgParams, new MutablePair<>(header, message));
}
项目:Catan    文件:CreateScreen.java   
public CreateScreen(CatanGame pGame, Screen parentScreen) {
    this.parentScreen = parentScreen;
    game = pGame;
    boardHexes = new ArrayList<>();
    boardOrigin = new MutablePair<>();
    setupBoardOrigin(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

}
项目:open-kilda    文件:CacheWarmingService.java   
/**
 * Put flows to local storage with cached state.
 * @param flows that will be added
 */
public void addPredefinedFlow(ImmutablePair<Flow, Flow> flows) {
    if (Objects.nonNull(flows.getLeft())) {
        predefinedFlows.add(new MutablePair<>(flows.getLeft(), CachedFlowState.CACHED));
    }
    if (Objects.nonNull(flows.getRight())) {
        predefinedFlows.add(new MutablePair<>(flows.getRight(), CachedFlowState.CACHED));
    }
}
项目:SamaGamesAPI    文件:TeamSpeakAPI.java   
public static boolean deleteChannel(int channelId)
{
    MutablePair<ResultType, Object> pair = MutablePair.of(ResultType.BOOLEAN, false);
    int id = generator++;
    TeamSpeakAPI.results.put(id, pair);
    TeamSpeakAPI.publish(id, "deletechannel:" + channelId);
    try
    {
       synchronized (pair)
       {
           pair.wait(TeamSpeakAPI.TIMEOUT);
       }
    } catch (Exception ignored) {}
    return (boolean)pair.getRight();
}
项目:SamaGamesAPI    文件:TeamSpeakAPI.java   
public static boolean isLinked(@Nonnull UUID uuid)
{
    MutablePair<ResultType, Object> pair = MutablePair.of(ResultType.BOOLEAN, false);
    int id = generator++;
    TeamSpeakAPI.results.put(id, pair);
    TeamSpeakAPI.publish(id, "linked:" + uuid);
    try
    {
        synchronized (pair)
        {
            pair.wait(TeamSpeakAPI.TIMEOUT);
        }
    } catch (Exception ignored) {}
    return (boolean)pair.getRight();
}
项目:SamaGamesAPI    文件:TeamSpeakAPI.java   
@Override
public void receive(String channel, String packet)
{
    String[] args = packet.split(":");
    String[] prefix = args[0].split("/");
    if (!prefix[0].equals(SamaGamesAPI.get().getServerName()))
        return ;
    int id = Integer.parseInt(prefix[1]);
    MutablePair<ResultType, Object> result = TeamSpeakAPI.results.get(id);
    TeamSpeakAPI.results.remove(id);
    boolean ok = args.length > 1 && !args[1].equals("ERROR");
    if (!ok)
        SamaGamesAPI.get().getPlugin().getLogger().severe("[TeamSpeakAPI] Error : " + (args.length > 2 ? args[2] : "Unknown") + "(packet = " + packet + ")");
    else
        switch (result.getLeft())
        {
            case UUID_LIST:
                List<UUID> uuid = (List<UUID>) result.getRight();
                for (int i = 1; i < args.length; i++)
                    uuid.add(UUID.fromString(args[i]));
                break;
            case INTEGER:
                result.setRight(Integer.parseInt(args[1]));
                break;
            case BOOLEAN:
                result.setRight(args[1].equalsIgnoreCase("OK") || args[1].equalsIgnoreCase("true"));
                break ;
            default:
                break ;
        }
    synchronized (result)
    {
        result.notifyAll();
    }
}
项目:Gather-Platform    文件:CommonWebpageDAO.java   
/**
 * 开始滚动数据
 *
 * @param queryBuilder 查询句柄
 * @return 滚动id和当前的一批数据
 */
public Pair<String, List<Webpage>> startScroll(QueryBuilder queryBuilder, int size) {
    SearchRequestBuilder searchRequestBuilder = client.prepareSearch(INDEX_NAME)
            .setTypes(TYPE_NAME)
            .setQuery(queryBuilder)
            .setSize(size)
            .setScroll(TimeValue.timeValueMinutes(SCROLL_TIMEOUT));
    SearchResponse response = searchRequestBuilder.execute().actionGet();
    return new MutablePair<>(response.getScrollId(), warpHits2List(response.getHits()));
}
项目:Machines-and-Stuff    文件:Registry.java   
public static int getBurnTime(ItemStack stack) {
    for(MutablePair<ItemStack, Integer> pair : basicCoalGenerator) {
        if(pair.left.isItemEqual(stack)) {
            return pair.right;
        }
    }
    return 0;
}
项目:Machines-and-Stuff    文件:Registry.java   
public static boolean containsItemStack(ItemStack stack) {
    for(MutablePair<ItemStack, Integer> pair : basicCoalGenerator) {
        if(stack != null && pair.left.isItemEqual(stack)) {
            return true;
        }
    }
    return false;
}
项目:Machines-and-Stuff    文件:Registry.java   
public static void removeBasicCoalGeneratorItem(ItemStack stack) {
    MutablePair<ItemStack, Integer> toRemove = null;
    for(MutablePair<ItemStack, Integer> pair : basicCoalGenerator) {
        if(pair.left.isItemEqual(stack)) {
            toRemove = pair;
        }
    }
    basicCoalGenerator.remove(toRemove);
}
项目:Machines-and-Stuff    文件:Registry.java   
public static List<ItemStack> getItemStacks() {
    List<ItemStack> list = new ArrayList<ItemStack>();
    for(MutablePair<ItemStack, Integer> pair : basicCoalGenerator) {
        list.add(pair.left);
    }
    return list;
}
项目:AgarMC    文件:AgarGame.java   
@Override
public Pair<Boolean, String> canJoinGame(UUID player, boolean reconnect)
{
    if (this.getPlayers().size() >= SamaGamesAPI.get().getGameManager().getGameProperties().getMaxSlots())
        return new MutablePair<>(false, "Serveur plein");
    return new MutablePair<>(true, null);
}