Example usage for org.apache.commons.lang3.tuple ImmutablePair ImmutablePair

List of usage examples for org.apache.commons.lang3.tuple ImmutablePair ImmutablePair

Introduction

In this page you can find the example usage for org.apache.commons.lang3.tuple ImmutablePair ImmutablePair.

Prototype

public ImmutablePair(final L left, final R right) 

Source Link

Document

Create a new pair instance.

Usage

From source file:com.github.drbookings.LocalDates.java

public static Pair<LocalDate, LocalDate> getFirstAndLastDayOfMonth(final int month) {
    final int year = LocalDate.now().getYear();
    final LocalDate firstDay = LocalDate.of(year, month, 1);
    final LocalDate lastDay = getLastDayOfMonth(firstDay);
    return new ImmutablePair<>(firstDay, lastDay);
}

From source file:hu.ppke.itk.nlpg.purepos.model.internal.HashLemmaTreeTest.java

@SuppressWarnings("unused")
private Pair<String, Integer> create(String s, Integer i) {
    return new ImmutablePair<String, Integer>(s, i);
}

From source file:com.wrmsr.neurosis.aws.ec2.Ec2InstanceTypeDetails.java

public static Map<String, Ec2InstanceTypeDetails> read() throws IOException {
    List<Ec2InstanceTypeDetails> lst;
    try (InputStream in = Ec2InstanceTypeDetails.class.getClassLoader().getResourceAsStream(RESOURCE)) {
        lst = Serialization.JSON_OBJECT_MAPPER.get().readValue(in,
                new TypeReference<List<Ec2InstanceTypeDetails>>() {
                });//from  w ww .  jav a2 s  . c o  m
    }
    return lst.stream().map(i -> new ImmutablePair<>(i.instanceType, i)).collect(toImmutableMap());
}

From source file:com.intuit.quickbase.devint.DBStatService.java

@Override
public List<Pair<String, Integer>> GetCountryPopulations() {

    List<Pair<String, Integer>> list = new ArrayList<Pair<String, Integer>>();

    try {// w w  w  .ja  v a 2 s. co  m

        System.out.println("Starting.");
        System.out.print("Getting DB Connection...");

        conn = getConnection();

        if (conn != null) {
            String query = "SELECT countryName, SUM(population) as population \n" + "FROM country c\n"
                    + " LEFT JOIN state s ON s.CountryID = c.CountryID\n"
                    + " LEFT JOIN city ON city.StateID = s.StateID\n" + "GROUP BY countryName\n"
                    + "ORDER BY countryName";

            ps = conn.prepareStatement(query);
            rs = ps.executeQuery();

            while (rs.next()) {

                ImmutablePair<String, Integer> pair = new ImmutablePair<String, Integer>(
                        rs.getString("countryName").toLowerCase(), rs.getInt("population"));
                //rs.getString("countryName");
                //rs.getString("population");                                        
                list.add(pair);
            }
            return list;
        } else {
            System.out.println("Connection failed.");
            return null;
        }

    } catch (SQLException ex) {
        Logger.getLogger(DBStatService.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        try {
            ps.close();
            rs.close();
            //close(conn);
        } catch (SQLException ex) {
            Logger.getLogger(DBStatService.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    return null;
}

From source file:com.trenako.utility.PeriodUtils.java

private static Pair<String, Integer> periodValue(BaseSingleFieldPeriod field) {
    String name = field.getPeriodType().getName().toLowerCase();
    int value = field.get(field.getFieldType());
    if (value > 1) {
        return new ImmutablePair<>("interval." + name + ".more.label", value);
    } else if (value > 0) {
        return new ImmutablePair<>("interval." + name + ".one.label", 1);
    }/*  www  . ja  v a2  s.c  o m*/

    return null;
}

From source file:com.ex.data.Direction.java

/**
 * Create Direction.//from w  w w  . j av  a2  s. c  om
 * @param connIdLeft Id of first Connector
 * @param beginPlintLeft Number of begin Plint in first pair
 * @param endPlintLeft Number of end Plint in first pair
 * @param connIdRight Id of second Connector
 * @param beginPlintRight Number of begin Plint in second pair
 * @param endPlintRight Number of end Plint in second pair
 */
public Direction(long connIdLeft, int beginPlintLeft, int endPlintLeft, long connIdRight, int beginPlintRight,
        int endPlintRight) {
    super(new ImmutablePair<>(connIdLeft, new ImmutablePair<>(beginPlintLeft, endPlintLeft)),
            new ImmutablePair<>(connIdRight, new ImmutablePair<>(beginPlintRight, endPlintRight)));
}

From source file:com.galenframework.parser.CommandLineReader.java

public Pair<String, String> readArgument() {
    if (hasNext()) {
        String argumentName = convertArgumentName(readNext());
        if (hasNext()) {
            String argumentValue = readNext();
            return new ImmutablePair<>(argumentName, argumentValue);
        } else {/*from  w w  w .  ja  v  a  2s . c o  m*/
            throw new IndexOutOfBoundsException("Argument '" + argumentName + "' doesn't have a value");
        }

    } else {
        throw new IndexOutOfBoundsException();
    }
}

From source file:io.pravega.controller.store.stream.tables.IndexRecord.java

private static Pair<Integer, Optional<IndexRecord>> binarySearchIndex(final int lower, final int upper,
        final long timestamp, final byte[] indexTable) {
    if (upper < lower || indexTable.length == 0) {
        return new ImmutablePair<>(0, Optional.empty());
    }//ww  w.  ja va  2  s.  c  om

    final int offset = ((lower + upper) / 2) * IndexRecord.INDEX_RECORD_SIZE;

    final IndexRecord record = IndexRecord.readRecord(indexTable, offset).get();

    final Optional<IndexRecord> next = IndexRecord.fetchNext(indexTable, offset);

    if (record.getEventTime() <= timestamp) {
        if (!next.isPresent() || (next.get().getEventTime() > timestamp)) {
            return new ImmutablePair<>(offset, Optional.of(record));
        } else {
            return binarySearchIndex((lower + upper) / 2 + 1, upper, timestamp, indexTable);
        }
    } else {
        return binarySearchIndex(lower, (lower + upper) / 2 - 1, timestamp, indexTable);
    }
}

From source file:com.videaps.cube.solving.moving.PrepareNotationDelegate.java

private Pair<String, String> split(String notation) {
    Pair<String, String> pair = null;

    if (notation.length() == 1) {
        pair = new ImmutablePair<String, String>(notation, "");
    } else if (notation.length() == 2) {
        pair = new ImmutablePair<String, String>(notation.substring(0, 1), notation.substring(1));
    }// w w  w .  j  a  v a  2  s.co m
    return pair;
}

From source file:com.netflix.bdp.inviso.history.impl.BucketedHistoryLocator.java

/**
 * Returns the config and history locations
  * @param jobId/*w w  w. j  a  va  2 s. c  om*/
  * @return 
 */
@Override
public Pair<Path, Path> locate(String jobId) {
    String bucket = jobId.substring(jobId.length() - conf.getInt("inviso.history.bucket.depth", 3));

    Path originConfig = new Path(bucketedPath + Path.SEPARATOR + bucket, jobId + configPostfix);
    Path originHistory = new Path(bucketedPath + Path.SEPARATOR + bucket, jobId + historyPostfix);

    return new ImmutablePair<>(originConfig, originHistory);
}