/** * <p> * Obtains an immutable pair of from two objects inferring the generic * types. * </p> * * <p> * This factory allows the pair to be created using inference to obtain the * generic types. * </p> * * @param <L> * the left element type * @param <R> * the right element type * @param left * the left element, may be null * @param right * the right element, may be null * @return a pair formed from the two parameters, not null * @since 1.4 */ public static <L, R> Pair<L, R> of(final L left, final R right) { return new Pair<L, R>(left, right); }
/** * <p> * Obtains an immutable pair of from two objects inferring the generic * types. * </p> * * <p> * This factory allows the pair to be created using inference to obtain the * generic types. * </p> * * @param <L> * the left element type * @param <R> * the right element type * @param left * the left element, may be null * @param right * the right element, may be null * @return a pair formed from the two parameters, not null * @since 1.4 */ public static <L, R> Pair<L, R> of(final L left, final R right) { return new Pair<L, R>(left, right); }
private Pair<Bundle, List<ConnectorInfo>> processBundle(Bundle bundle, List<ManifestEntry> list) { Pair<Bundle, List<ConnectorInfo>> result = null; try { List<ConnectorInfo> info = createConnectorInfo(bundle, list); if (!info.isEmpty()) { result = new Pair<>(bundle, info); } } catch (Throwable t) { LOG.error("ConnectorBundel {} loading failed.", bundle.getSymbolicName(), t); } return result; }
@Test public void hash() { Set<Pair<Integer, Integer>> set = new HashSet<>(); for (int i = 0; i < 20; i++) { Pair<Integer, Integer> pair = new Pair<>(i, i + 1); Pair<Integer, Integer> tst = new Pair<>(i, i + 1); set.add(pair); assertTrue(set.contains(tst)); } // check that each pair is unique.. assertEquals(20, set.size()); } }