org.apache.commons.lang3.tuple.Triple.getMiddle()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(13.3k)|赞(0)|评价(0)|浏览(78)

本文整理了Java中org.apache.commons.lang3.tuple.Triple.getMiddle()方法的一些代码示例,展示了Triple.getMiddle()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Triple.getMiddle()方法的具体详情如下:
包路径:org.apache.commons.lang3.tuple.Triple
类名称:Triple
方法名:getMiddle

Triple.getMiddle介绍

[英]Gets the middle element from this triple.
[中]从这个三元组中获取中间元素。

代码示例

代码示例来源:origin: apache/incubator-gobblin

@Override
public GoogleWebmasterFilter.FilterOperator getOperator() {
 return _jobNode.getMiddle();
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * <p>Returns a suitable hash code.</p>
 *
 * @return the hash code
 */
@Override
public int hashCode() {
  return (getLeft() == null ? 0 : getLeft().hashCode()) ^
    (getMiddle() == null ? 0 : getMiddle().hashCode()) ^
    (getRight() == null ? 0 : getRight().hashCode());
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * <p>Formats the receiver using the given format.</p>
 *
 * <p>This uses {@link java.util.Formattable} to perform the formatting. Three variables may
 * be used to embed the left and right elements. Use {@code %1$s} for the left
 * element, {@code %2$s} for the middle and {@code %3$s} for the right element.
 * The default format used by {@code toString()} is {@code (%1$s,%2$s,%3$s)}.</p>
 *
 * @param format  the format string, optionally containing {@code %1$s}, {@code %2$s} and {@code %3$s}, not null
 * @return the formatted string, not null
 */
public String toString(final String format) {
  return String.format(format, getLeft(), getMiddle(), getRight());
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * <p>Returns a String representation of this triple using the format {@code ($left,$middle,$right)}.</p>
 *
 * @return a string describing this object, not null
 */
@Override
public String toString() {
  return "(" + getLeft() + "," + getMiddle() + "," + getRight() + ")";
}

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * <p>Compares this triple to another based on the three elements.</p>
 *
 * @param obj  the object to compare to, null returns false
 * @return true if the elements of the triple are equal
 */
@Override
public boolean equals(final Object obj) {
  if (obj == this) {
    return true;
  }
  if (obj instanceof Triple<?, ?, ?>) {
    final Triple<?, ?, ?> other = (Triple<?, ?, ?>) obj;
    return Objects.equals(getLeft(), other.getLeft())
      && Objects.equals(getMiddle(), other.getMiddle())
      && Objects.equals(getRight(), other.getRight());
  }
  return false;
}

代码示例来源:origin: ethereum/ethereumj

public PendingTransactionState pollTxUpdateState(Transaction tx) throws InterruptedException {
  return getQueueFor(tx).poll(5, SECONDS).getMiddle();
}
public Triple<TransactionReceipt, PendingTransactionState, Block> pollTxUpdate(Transaction tx) throws InterruptedException {

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * <p>Compares the triple based on the left element, followed by the middle element,
 * finally the right element.
 * The types must be {@code Comparable}.</p>
 *
 * @param other  the other triple, not null
 * @return negative if this is less, zero if equal, positive if greater
 */
@Override
public int compareTo(final Triple<L, M, R> other) {
 return new CompareToBuilder().append(getLeft(), other.getLeft())
   .append(getMiddle(), other.getMiddle())
   .append(getRight(), other.getRight()).toComparison();
}

代码示例来源:origin: apache/incubator-pinot

public static ServerInstance forHostPort(String name, int port) {
 if (nameToInstanceInfo.containsKey(name)) {
  Triple<String, String, InetAddress> instanceInfo = nameToInstanceInfo.get(name);
  return new ServerInstance(instanceInfo.getLeft(), instanceInfo.getMiddle(), instanceInfo.getRight(), port, 0);
 } else {
  ServerInstance newInstance = new ServerInstance(name, port);
  nameToInstanceInfo.putIfAbsent(name,
    Triple.of(newInstance.getHostname(), newInstance.getShortHostName(), newInstance.getIpAddress()));
  return newInstance;
 }
}

代码示例来源:origin: apache/incubator-gobblin

/**
 * Get the detailed pages under this group
 */
public static ArrayList<String> groupToPages(Triple<String, GoogleWebmasterFilter.FilterOperator, UrlTrieNode> group) {
 ArrayList<String> ret = new ArrayList<>();
 if (group.getMiddle().equals(GoogleWebmasterFilter.FilterOperator.EQUALS)) {
  if (group.getRight().isExist()) {
   ret.add(group.getLeft());
  }
 } else if (group.getMiddle().equals(GoogleWebmasterFilter.FilterOperator.CONTAINS)) {
  UrlTrie trie = new UrlTrie(group.getLeft(), group.getRight());
  Iterator<Pair<String, UrlTrieNode>> iterator = new UrlTriePostOrderIterator(trie, 1);
  while (iterator.hasNext()) {
   Pair<String, UrlTrieNode> next = iterator.next();
   if (next.getRight().isExist()) {
    ret.add(next.getLeft());
   }
  }
 }
 return ret;
}

代码示例来源:origin: apache/hive

private HiveTableScan(RelOptCluster cluster, RelTraitSet traitSet, RelOptHiveTable table,
  String alias, String concatQbIDAlias, RelDataType newRowtype, boolean useQBIdInDigest, boolean insideView) {
 super(cluster, TraitsUtil.getDefaultTraitSet(cluster), table);
 assert getConvention() == HiveRelNode.CONVENTION;
 this.tblAlias = alias;
 this.concatQbIDAlias = concatQbIDAlias;
 this.hiveTableScanRowType = newRowtype;
 Triple<ImmutableList<Integer>, ImmutableSet<Integer>, ImmutableSet<Integer>> colIndxPair =
   buildColIndxsFrmReloptHT(table, newRowtype);
 this.neededColIndxsFrmReloptHT = colIndxPair.getLeft();
 this.virtualOrPartColIndxsInTS = colIndxPair.getMiddle();
 this.virtualColIndxsInTS = colIndxPair.getRight();
 this.useQBIdInDigest = useQBIdInDigest;
 this.insideView = insideView;
}

代码示例来源:origin: apache/incubator-gobblin

/**
 * The trie is:
 *     /
 *     0*
 *  1*    2*
 */
@Test
public void testGrouping2() {
 UrlTrie trie = new UrlTrie(_property, Arrays.asList(_property + "0", _property + "01", _property + "02"));
 UrlTriePrefixGrouper grouper = new UrlTriePrefixGrouper(trie, 1);
 ArrayList<String> chars = new ArrayList<>();
 ArrayList<FilterOperator> operators = new ArrayList<>();
 while (grouper.hasNext()) {
  Triple<String, FilterOperator, UrlTrieNode> group = grouper.next();
  chars.add(group.getLeft());
  operators.add(group.getMiddle());
 }
 Assert.assertEquals(new String[]{_property + "01", _property + "02", _property + "0"}, chars.toArray());
 Assert.assertEquals(new FilterOperator[]{FilterOperator.CONTAINS, FilterOperator.CONTAINS, FilterOperator.EQUALS},
   operators.toArray());
}

代码示例来源:origin: apache/incubator-gobblin

/**
 * The trie is:
 *     /
 *     0
 *  1*   2*
 */
@Test
public void testGrouping1() {
 UrlTrie trie = new UrlTrie(_property, Arrays.asList(_property + "01", _property + "02"));
 UrlTriePrefixGrouper grouper = new UrlTriePrefixGrouper(trie, 1);
 ArrayList<String> chars = new ArrayList<>();
 ArrayList<FilterOperator> operators = new ArrayList<>();
 while (grouper.hasNext()) {
  Triple<String, FilterOperator, UrlTrieNode> group = grouper.next();
  chars.add(group.getLeft());
  operators.add(group.getMiddle());
 }
 Assert.assertEquals(new String[]{_property + "01", _property + "02"}, chars.toArray());
 Assert.assertEquals(new FilterOperator[]{FilterOperator.CONTAINS, FilterOperator.CONTAINS}, operators.toArray());
}

代码示例来源:origin: apache/incubator-gobblin

@Test
public void testWhenTrieSizeLessThanGroupSize1() {
 List<String> pages = Arrays.asList(_property + "13");
 UrlTrie trie1 = new UrlTrie(_property, pages);
 UrlTriePrefixGrouper grouper = new UrlTriePrefixGrouper(trie1, 1);
 Triple<String, FilterOperator, UrlTrieNode> next = grouper.next();
 Assert.assertEquals(next.getLeft(), _property);
 Assert.assertEquals(next.getMiddle(), FilterOperator.CONTAINS);
 Assert.assertEquals(next.getRight().getValue(), Character.valueOf('/'));
 Assert.assertFalse(next.getRight().isExist());
 Assert.assertFalse(grouper.hasNext());
}

代码示例来源:origin: apache/incubator-gobblin

@Test
public void testWhenTrieSizeLessThanGroupSize2() {
 List<String> pages = Arrays.asList(_property + "13");
 UrlTrie trie1 = new UrlTrie(_property, pages);
 UrlTriePrefixGrouper grouper = new UrlTriePrefixGrouper(trie1, 2);
 Triple<String, FilterOperator, UrlTrieNode> next = grouper.next();
 Assert.assertEquals(next.getLeft(), _property);
 Assert.assertEquals(next.getMiddle(), FilterOperator.CONTAINS);
 Assert.assertEquals(next.getRight().getValue(), Character.valueOf('/'));
 Assert.assertFalse(next.getRight().isExist());
 Assert.assertFalse(grouper.hasNext());
}

代码示例来源:origin: apache/incubator-gobblin

/**
 * The trie is:
 *     /
 *  0  1  2
 * 3 4   5 6
 *       7
 */
@Test
public void testTrie2GroupingWithSize3() {
 UrlTrie trie = UrlTriePostOrderIteratorTest.getUrlTrie2(_property);
 UrlTriePrefixGrouper grouper = new UrlTriePrefixGrouper(trie, 3);
 ArrayList<String> chars = new ArrayList<>();
 ArrayList<FilterOperator> operators = new ArrayList<>();
 Triple<String, FilterOperator, UrlTrieNode> group = null;
 while (grouper.hasNext()) {
  group = grouper.next();
  chars.add(group.getLeft());
  operators.add(group.getMiddle());
 }
 Assert.assertEquals(
   new String[]{_property + "0", _property + "1", _property + "25", _property + "26", _property + "2"},
   chars.toArray());
 Assert.assertEquals(
   new FilterOperator[]{FilterOperator.CONTAINS, FilterOperator.CONTAINS, FilterOperator.CONTAINS, FilterOperator.CONTAINS, FilterOperator.EQUALS},
   operators.toArray());
 //The group is at www.linkedin.com/2 in the end with operator EQUALS
 ArrayList<String> pages = UrlTriePrefixGrouper.groupToPages(group);
 Assert.assertEquals(pages.toArray(), new String[]{_property + "2"});
}

代码示例来源:origin: ethereum/ethereumj

@Test
public void testBlockOnlyIncluded() throws InterruptedException {
  StandaloneBlockchain bc = new StandaloneBlockchain();
  PendingListener l = new PendingListener();
  bc.addEthereumListener(l);
  Triple<TransactionReceipt, EthereumListener.PendingTransactionState, Block> txUpd = null;
  PendingStateImpl pendingState = (PendingStateImpl) bc.getBlockchain().getPendingState();
  ECKey alice = new ECKey();
  ECKey bob = new ECKey();
  bc.sendEther(bob.getAddress(), convert(100, ETHER));
  Block b1 = bc.createBlock();
  Transaction tx1 = bc.createTransaction(bob, 0, alice.getAddress(), BigInteger.valueOf(1000000), new byte[0]);
  bc.submitTransaction(tx1);
  Block b2 = bc.createBlock();
  Block b2_ = bc.createForkBlock(b1);
  Assert.assertTrue(l.getQueueFor(tx1).isEmpty());
  Block b3_ = bc.createForkBlock(b2_);
  txUpd = l.pollTxUpdate(tx1);
  Assert.assertEquals(txUpd.getMiddle(), PENDING);
}

代码示例来源:origin: ethereum/ethereumj

Assert.assertEquals(txUpd.getMiddle(), INCLUDED);
Assert.assertTrue(l.getQueueFor(tx1).isEmpty());
Block b4_ = bc.createForkBlock(b3_);
txUpd = l.pollTxUpdate(tx1);
Assert.assertEquals(txUpd.getMiddle(), INCLUDED);
Assert.assertArrayEquals(txUpd.getRight().getHash(), b2_.getHash());
Block b5 = bc.createForkBlock(b4);
txUpd = l.pollTxUpdate(tx1);
Assert.assertEquals(txUpd.getMiddle(), INCLUDED);
Assert.assertArrayEquals(txUpd.getRight().getHash(), b2.getHash());

代码示例来源:origin: ethereum/ethereumj

@Test
public void testTrackTx2() throws InterruptedException {
  StandaloneBlockchain bc = new StandaloneBlockchain();
  PendingListener l = new PendingListener();
  bc.addEthereumListener(l);
  Triple<TransactionReceipt, EthereumListener.PendingTransactionState, Block> txUpd = null;
  PendingStateImpl pendingState = (PendingStateImpl) bc.getBlockchain().getPendingState();
  ECKey alice = new ECKey();
  ECKey bob = new ECKey();
  bc.sendEther(bob.getAddress(), convert(100, ETHER));
  Block b1 = bc.createBlock();
  Transaction tx1 = bc.createTransaction(bob, 0, alice.getAddress(), BigInteger.valueOf(1000000), new byte[0]);
  bc.submitTransaction(tx1);
  Block b2 = bc.createBlock();
  Assert.assertTrue(l.getQueueFor(tx1).isEmpty());
  pendingState.trackTransaction(tx1);
  txUpd = l.pollTxUpdate(tx1);
  Assert.assertEquals(txUpd.getMiddle(), INCLUDED);
  Assert.assertArrayEquals(txUpd.getRight().getHash(), b2.getHash());
  Block b2_ = bc.createForkBlock(b1);
  Block b3_ = bc.createForkBlock(b2_);
  Assert.assertEquals(l.pollTxUpdateState(tx1), PENDING);
}

代码示例来源:origin: ethereum/ethereumj

@Test
public void testOldBlockIncluded() throws InterruptedException {
  StandaloneBlockchain bc = new StandaloneBlockchain();
  PendingListener l = new PendingListener();
  bc.addEthereumListener(l);
  Triple<TransactionReceipt, EthereumListener.PendingTransactionState, Block> txUpd = null;
  PendingStateImpl pendingState = (PendingStateImpl) bc.getBlockchain().getPendingState();
  ECKey alice = new ECKey();
  ECKey bob = new ECKey();
  ECKey charlie = new ECKey();
  bc.sendEther(bob.getAddress(), convert(100, ETHER));
  Block b1 = bc.createBlock();
  for (int i = 0; i < 16; i++) {
    bc.createBlock();
  }
  Transaction tx1 = bc.createTransaction(bob, 0, alice.getAddress(), BigInteger.valueOf(1000000), new byte[0]);
  pendingState.addPendingTransaction(tx1);
  Assert.assertEquals(l.pollTxUpdateState(tx1), NEW_PENDING);
  bc.submitTransaction(tx1);
  Block b2_ = bc.createForkBlock(b1);
  Assert.assertTrue(l.getQueueFor(tx1).isEmpty());
  bc.submitTransaction(tx1);
  Block b18 = bc.createBlock();
  txUpd = l.pollTxUpdate(tx1);
  Assert.assertEquals(txUpd.getMiddle(), INCLUDED);
  Assert.assertArrayEquals(txUpd.getRight().getHash(), b18.getHash());
}

代码示例来源:origin: ethereum/ethereumj

@Test
public void testTrackTx1() throws InterruptedException {
  StandaloneBlockchain bc = new StandaloneBlockchain();
  PendingListener l = new PendingListener();
  bc.addEthereumListener(l);
  Triple<TransactionReceipt, EthereumListener.PendingTransactionState, Block> txUpd = null;
  PendingStateImpl pendingState = (PendingStateImpl) bc.getBlockchain().getPendingState();
  ECKey alice = new ECKey();
  ECKey bob = new ECKey();
  bc.sendEther(bob.getAddress(), convert(100, ETHER));
  Block b1 = bc.createBlock();
  Block b2 = bc.createBlock();
  Block b3 = bc.createBlock();
  Transaction tx1 = bc.createTransaction(bob, 0, alice.getAddress(), BigInteger.valueOf(1000000), new byte[0]);
  bc.submitTransaction(tx1);
  Block b2_ = bc.createForkBlock(b1);
  Assert.assertTrue(l.getQueueFor(tx1).isEmpty());
  pendingState.trackTransaction(tx1);
  Assert.assertEquals(l.pollTxUpdateState(tx1), NEW_PENDING);
  Block b3_ = bc.createForkBlock(b2_);
  Block b4_ = bc.createForkBlock(b3_);
  txUpd = l.pollTxUpdate(tx1);
  Assert.assertEquals(txUpd.getMiddle(), INCLUDED);
  Assert.assertArrayEquals(txUpd.getRight().getHash(), b2_.getHash());
}

相关文章

微信公众号

最新文章

更多