List of usage examples for org.apache.commons.lang3.tuple Pair getRight
public abstract R getRight();
Gets the right element from this pair.
When treated as a key-value pair, this is the value.
From source file:com.epam.catgenome.util.HistogramUtils.java
/** * Creates a {@link Wig} histogram block and adds it to histogram portion, if blockValue > 0 * @param histogram a List of {@link Wig} blocks, representing histogram * @param blockValue a value of histogram block, e.g. amount of features, fitting in interval * @param interval block's interval/* ww w .java2 s. c o m*/ */ public static void addToHistogramPortion(final List<Wig> histogram, final int blockValue, final Pair<Integer, Integer> interval) { if (blockValue > 0) { Wig result = new Wig(); result.setStartIndex(interval.getLeft()); result.setEndIndex(interval.getRight()); result.setValue((float) blockValue); histogram.add(result); } }
From source file:com.twitter.distributedlog.TestDistributedLogBase.java
@BeforeClass public static void setupCluster() throws Exception { File zkTmpDir = IOUtils.createTempDir("zookeeper", "distrlog"); tmpDirs.add(zkTmpDir);//from w w w. j a v a 2s . co m Pair<ZooKeeperServerShim, Integer> serverAndPort = LocalDLMEmulator.runZookeeperOnAnyPort(zkTmpDir); zks = serverAndPort.getLeft(); zkPort = serverAndPort.getRight(); bkutil = LocalDLMEmulator.newBuilder().numBookies(numBookies).zkHost("127.0.0.1").zkPort(zkPort) .serverConf(DLMTestUtil.loadTestBkConf()).shouldStartZK(false).build(); bkutil.start(); zkServers = "127.0.0.1:" + zkPort; }
From source file:com.formkiq.core.webflow.FlowManager.java
/** * Get Event Id./*from ww w. j a va2s . c om*/ * @param request {@link HttpServletRequest} * @return int */ public static int getEventId(final HttpServletRequest request) { Pair<String, Integer> webflowkey = getExecutionSessionKey(request.getParameter(PARAMETER_EXECUTION)); Integer eventId = webflowkey.getRight(); return eventId != null ? eventId.intValue() : 1; }
From source file:alfio.model.modification.support.LocationDescriptor.java
public static LocationDescriptor fromGeoData(Pair<String, String> coordinates, TimeZone timeZone, Map<ConfigurationKeys, Optional<String>> geoConf) { Map<String, String> params = new HashMap<>(); String lat = coordinates.getLeft(); String lng = coordinates.getRight(); params.put("latitude", lat); params.put("longitude", lng); return new LocationDescriptor(timeZone.getID(), coordinates.getLeft(), coordinates.getRight(), getMapUrl(lat, lng, geoConf)); }
From source file:edu.wpi.checksims.testutil.AlgorithmUtils.java
/** * Ensure that every pair in a set of pairs is representing in algorithm results * * @param results Collection of algorithm results to check in * @param pairs Pairs of submissions to search for in the results *///w w w .j ava 2s . com public static void checkResultsContainsPairs(Collection<AlgorithmResults> results, Set<Pair<Submission, Submission>> pairs) { assertNotNull(results); assertNotNull(pairs); assertEquals(results.size(), pairs.size()); for (Pair<Submission, Submission> pair : pairs) { long numWithResult = results.stream().filter((result) -> { return (result.a.equals(pair.getLeft()) && result.b.equals(pair.getRight())) || (result.a.equals(pair.getRight()) && result.b.equals(pair.getLeft())); }).count(); assertEquals(1, numWithResult); } }
From source file:com.nttec.everychan.ui.tabs.LocalHandler.java
public static TabModel getTabModel(String filename, Resources resources) { File file = new File(filename); if (file.exists() && !file.isDirectory()) { String lfilename = filename.toLowerCase(Locale.US); if (!lfilename.endsWith(".zip") && !lfilename.endsWith(".mht") && !lfilename.endsWith(".mhtml")) { file = file.getParentFile(); filename = file.getAbsolutePath(); }/*from w ww. j a v a 2 s. com*/ } ReadableContainer zip = null; UrlPageModel pageModel; String pageTitle; try { zip = ReadableContainer.obtain(file); Pair<String, UrlPageModel> p = MainApplication.getInstance().serializer .loadPageInfo(zip.openStream(DownloadingService.MAIN_OBJECT_FILE)); pageTitle = p.getLeft(); pageModel = p.getRight(); } catch (Exception e) { Logger.e(TAG, e); MainApplication.getInstance().database.removeSavedThread(filename); return null; } finally { try { if (zip != null) zip.close(); } catch (IOException e) { e.printStackTrace(); } } TabModel model = new TabModel(); model.type = TabModel.TYPE_LOCAL; model.id = new Random().nextLong(); model.title = pageTitle; model.pageModel = pageModel; model.hash = CryptoUtils.computeMD5(filename); try { model.webUrl = MainApplication.getInstance().getChanModule(pageModel.chanName).buildUrl(pageModel); } catch (IllegalArgumentException e) { model.webUrl = null; } catch (NullPointerException e) { return null; } model.localFilePath = filename; model.forceUpdate = true; return model; }
From source file:com.silverpeas.gallery.dao.OrderDAO.java
/** * Finds orders from the specified criteria. * @param con/* ww w. j a v a 2 s . c o m*/ * @param criteria * @return a list of orders, empty if no order found. */ public static List<Order> findByCriteria(final Connection con, MediaOrderCriteria criteria) throws SQLException { MediaOrderSQLQueryBuilder queryBuilder = new MediaOrderSQLQueryBuilder(); criteria.processWith(queryBuilder); Pair<String, List<Object>> queryBuild = queryBuilder.result(); return queryBuilder.orderingResult( select(con, queryBuild.getLeft(), queryBuild.getRight(), new SelectResultRowProcessor<Order>() { @Override protected Order currentRow(final int rowIndex, final ResultSet rs) throws SQLException { Order order = new Order(rs.getString(1)); order.setUserId(rs.getString(2)); order.setInstanceId(rs.getString(3)); order.setCreationDate(rs.getTimestamp(4)); order.setProcessDate(rs.getTimestamp(5)); order.setProcessUserId(rs.getString(6)); order.setRows(getAllOrderDetails(con, order.getOrderId())); return order; } })); }
From source file:forge.properties.ForgeProfileProperties.java
public static void load() { final Properties props = new Properties(); final File propFile = new File(ForgeConstants.PROFILE_FILE); try {//w ww . j a v a 2 s. c o m if (propFile.canRead()) { props.load(new FileInputStream(propFile)); } } catch (final IOException e) { System.err.println("error while reading from profile properties file"); } final Pair<String, String> defaults = getDefaultDirs(); userDir = getDir(props, USER_DIR_KEY, defaults.getLeft()); cacheDir = getDir(props, CACHE_DIR_KEY, defaults.getRight()); cardPicsDir = getDir(props, CARD_PICS_DIR_KEY, cacheDir + "pics" + File.separator + "cards" + File.separator); cardPicsSubDirs = getMap(props, CARD_PICS_SUB_DIRS_KEY); serverPort = getInt(props, SERVER_PORT_KEY, 36743); // "Forge" using phone keypad //ensure directories exist FileUtil.ensureDirectoryExists(userDir); FileUtil.ensureDirectoryExists(cacheDir); FileUtil.ensureDirectoryExists(cardPicsDir); }
From source file:com.streamsets.pipeline.stage.origin.jdbc.table.ReferentialConstraintOrderingIT.java
@BeforeClass public static void setupTables() throws SQLException { populateRecords();/*from w ww . java 2 s. com*/ try (Statement statement = connection.createStatement()) { //USER_TABLE TABLE statement.addBatch( "CREATE TABLE TEST.USER_TABLE (u_id INT PRIMARY KEY, name varchar(100), address varchar(1000))"); //PRODUCT TABLE statement.addBatch("CREATE TABLE TEST.PRODUCT" + " (p_id INT PRIMARY KEY, name varchar(100), manufacturer varchar(1000))"); statement.addBatch("CREATE TABLE TEST.ORDER_TBL" + " (o_id INT PRIMARY KEY, u_id INT, FOREIGN KEY (u_id) REFERENCES TEST.USER_TABLE(u_id))"); //ITEMS TABLE //We do not support composite keys so for now the primary key here is a timestamp. statement.addBatch("CREATE TABLE TEST.ITEMS (" + "time_id BIGINT PRIMARY KEY, o_id INT," + " p_id INT, quantity int," + " FOREIGN KEY (o_id) REFERENCES TEST.ORDER_TBL(o_id), FOREIGN KEY (p_id) REFERENCES TEST.PRODUCT(p_id))"); statement.executeBatch(); } for (Pair<String, ArrayList<Record>> value : TABLE_TO_TEMPLATE_AND_RECORDS_MAP.values()) { insertRows(value.getLeft(), value.getRight()); } }
From source file:forge.properties.ForgeProfileProperties.java
private static void save() { final Pair<String, String> defaults = getDefaultDirs(); final String defaultUserDir = defaults.getLeft() + File.separator; final String defaultCacheDir = defaults.getRight() + File.separator; final String defaultCardPicsDir = defaultCacheDir + "pics" + File.separator + "cards" + File.separator; //only append values that aren't equal to defaults final StringBuilder sb = new StringBuilder(); if (!userDir.equals(defaultUserDir)) { //ensure backslashes are escaped sb.append(USER_DIR_KEY + "=" + userDir.replace("\\", "\\\\") + "\n"); }//www . jav a 2 s. c o m if (!cacheDir.equals(defaultCacheDir)) { sb.append(CACHE_DIR_KEY + "=" + cacheDir.replace("\\", "\\\\") + "\n"); } if (!cardPicsDir.equals(defaultCardPicsDir)) { sb.append(CARD_PICS_DIR_KEY + "=" + cardPicsDir.replace("\\", "\\\\") + "\n"); } if (cardPicsSubDirs.size() > 0) { sb.append(CARD_PICS_SUB_DIRS_KEY + "="); final boolean needDelim = false; for (final Map.Entry<String, String> entry : cardPicsSubDirs.entrySet()) { if (needDelim) { sb.append("|"); } sb.append(entry.getKey() + "->" + entry.getValue()); } sb.append("\n"); } if (serverPort != 0) { sb.append(SERVER_PORT_KEY + "=" + serverPort); } if (sb.length() > 0) { FileUtil.writeFile(ForgeConstants.PROFILE_FILE, sb.toString()); } else { //delete file if empty try { final File file = new File(ForgeConstants.PROFILE_FILE); if (file.exists()) { file.delete(); } } catch (final Exception e) { e.printStackTrace(); } } }