Example usage for org.apache.commons.lang3.tuple Pair getRight

List of usage examples for org.apache.commons.lang3.tuple Pair getRight

Introduction

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

Prototype

public abstract R getRight();

Source Link

Document

Gets the right element from this pair.

When treated as a key-value pair, this is the value.

Usage

From source file:net.minecraftforge.fml.relauncher.libraries.LibraryManager.java

private static void cleanDirectory(File dir, ModList modlist, File... modDirs) {
    if (!dir.exists())
        return;/*w w w .  ja  v  a 2  s  .  c om*/

    FMLLog.log.debug("Cleaning up mods folder: {}", dir);
    for (File file : dir.listFiles(f -> f.isFile() && f.getName().endsWith(".jar"))) {
        Pair<Artifact, byte[]> ret = extractPacked(file, modlist, modDirs);
        if (ret != null) {
            Artifact artifact = ret.getLeft();
            Repository repo = modlist.getRepository() == null ? libraries_dir : modlist.getRepository();
            File moved = repo.archive(artifact, file, ret.getRight());
            processed.add(moved);
        }
    }

    try {
        if (modlist.changed())
            modlist.save();
    } catch (IOException e) {
        FMLLog.log.error(
                FMLLog.log.getMessageFactory().newMessage("Error updating modlist file {}", modlist.getName()),
                e);
    }
}

From source file:com.act.lcms.v2.MassChargeCalculator.java

protected static Double computeMass(MZSource mzSource) {
    Double mass;/*from  w w  w.j  a va 2s  . co m*/
    String msg;
    switch (mzSource.getKind()) {
    case INCHI:
        Pair<Double, Integer> massAndCharge;
        try {
            massAndCharge = MassCalculator.calculateMassAndCharge(mzSource.getInchi());
        } catch (Exception e) {
            LOGGER.error("Calculating mass for molecule %s failed: %s", mzSource.getInchi(), e.getMessage());
            throw e;
        }
        if (massAndCharge.getRight() > 0) {
            LOGGER.warn(
                    "(MZSrc %d) Molecule %s has a positive charge %d; ionization may not have the expected effect",
                    mzSource.getId(), mzSource.getInchi(), massAndCharge.getRight());
        } else if (massAndCharge.getRight() < 0) {
            LOGGER.warn("(MZSrc %d) Molecule %s has a negative charge %d; it may not fly in positive ion mode",
                    mzSource.getId(), mzSource.getInchi(), massAndCharge.getRight());
        }
        mass = massAndCharge.getLeft();
        break;
    case ARBITRARY_MASS:
        mass = mzSource.getArbitraryMass();
        break;
    case PRE_EXTRACTED_MASS:
        mass = mzSource.getPreExtractedMass().getRight();
        break;
    case UNKNOWN:
        msg = String.format("mzSource with id %d has UNKNOWN kind, which is invalid", mzSource.getId());
        LOGGER.error(msg);
        throw new RuntimeException(msg);
    default:
        msg = String.format("mzSource with id %d has unknown kind (should be impossible): %s", mzSource.getId(),
                mzSource.getKind());
        LOGGER.error(msg);
        throw new RuntimeException(msg);
    }
    return mass;
}

From source file:com.joyent.manta.http.HttpDownloadContinuationMarker.java

/**
 * Builds a download marker after confirming that the initial response matches any hints that the initial request
 * supplied. If a hint is missing it will not be checked. If the response
 *
 * @param requestHints etag and range from initial request (If-Match and Range)
 * @param responseFingerprint etag and range from initial response (ETag and Content-Range)
 * @return a marker which can be used to track download progress and verify future responses
 * @throws ProtocolException thrown when a hint is provided but not satisfied
 *//*from w w  w .  j a v a2 s .co m*/
static HttpDownloadContinuationMarker validateInitialExchange(final Pair<String, Request> requestHints,
        final int responseCode, final Pair<String, Response> responseFingerprint) throws ProtocolException {

    // there was an if-match header and the response etag does not match
    if (requestHints.getLeft() != null && !requestHints.getLeft().equals(responseFingerprint.getLeft())) {
        throw new ProtocolException(String.format("ETag does not match If-Match: If-Match [%s], ETag [%s]",
                requestHints.getLeft(), responseFingerprint.getLeft()));

    }

    final boolean rangeRequest = requestHints.getRight() != null;

    // there was a request range and an invalid response range (or none) was returned
    // Note: we should use the more complete range (the response range) to invoke match so as many values are
    // compared as possible
    if (rangeRequest && !requestHints.getRight().matches(responseFingerprint.getRight())) {
        throw new ProtocolException(
                String.format("Content-Range does not match Request range: Range [%s], Content-Range [%s]",
                        requestHints.getRight(), responseFingerprint.getRight()));
    }

    // if there was a request range the response code should be 206
    if (rangeRequest && responseCode != SC_PARTIAL_CONTENT) {
        throw new ProtocolException(
                String.format("Unexpected response code for range request: expected [%d], got [%d]",
                        SC_PARTIAL_CONTENT, responseCode));
    }

    // if there was no request range the response code should be 200
    if (!rangeRequest && responseCode != SC_OK) {
        throw new ProtocolException(
                String.format("Unexpected response code for non-range request: expected [%d], got [%d]", SC_OK,
                        responseCode));

    }

    return new HttpDownloadContinuationMarker(responseFingerprint.getLeft(), responseFingerprint.getRight());
}

From source file:com.act.lcms.db.analysis.AnalysisHelper.java

private static <A, B> Pair<List<A>, List<B>> split(List<Pair<A, B>> lpairs) {
    List<A> a = new ArrayList<>();
    List<B> b = new ArrayList<>();
    for (Pair<A, B> p : lpairs) {
        a.add(p.getLeft());/*from   w  w w  .j  a  va2  s  . c o  m*/
        b.add(p.getRight());
    }
    return Pair.of(a, b);
}

From source file:com.stratelia.webactiv.util.DBUtil.java

/**
 * Update query executor.//from   www .ja  v  a 2s  . c om
 * @param con
 * @param updateQueries
 * @throws SQLException
 */
public static <O> long executeUpdate(Connection con, List<Pair<String, List<O>>> updateQueries)
        throws SQLException {
    long nbUpdate = 0;
    for (Pair<String, List<O>> updateQuery : updateQueries) {
        nbUpdate += executeUpdate(con, updateQuery.getLeft(), updateQuery.getRight());
    }
    return nbUpdate;
}

From source file:com.act.lcms.db.model.ScanFile.java

public static List<Pair<Integer, DB.OPERATION_PERFORMED>> insertOrUpdateScanFilesInDirectory(DB db,
        File directory) throws SQLException, IOException {
    if (directory == null || !directory.isDirectory()) {
        throw new RuntimeException(String.format("Scan files directory at %s is not a directory",
                directory == null ? null : directory.getAbsolutePath()));
    }/* w w  w .j ava 2  s . c  om*/

    List<Pair<Integer, DB.OPERATION_PERFORMED>> results = new ArrayList<>();

    File[] contentsArr = directory.listFiles();

    if (contentsArr == null || contentsArr.length == 0) {
        System.err.format("WARNING: no files found in directory %s", directory.getAbsolutePath());
        return null;
    }
    List<File> contents = Arrays.asList(contentsArr);
    Collections.sort(contents, new Comparator<File>() {
        @Override
        public int compare(File o1, File o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });

    for (File f : contents) {
        for (Pair<Pattern, Map<SCAN_NAME_COMPONENT, Integer>> scan : NAME_EXTRACTION_PATTERNS) {
            Pattern p = scan.getLeft();
            Map<SCAN_NAME_COMPONENT, Integer> groupMap = scan.getRight();
            Matcher m = p.matcher(f.getName());
            if (m.matches()) {
                if (groupMap.containsKey(SCAN_NAME_COMPONENT.SCAN_PART)) {
                    String scanPartStr = m.group(groupMap.get(SCAN_NAME_COMPONENT.SCAN_PART));
                    if (scanPartStr != null && !scanPartStr.isEmpty()) {
                        Integer scanPart = Integer.parseInt(scanPartStr);
                        if (!LCMS_MAIN_SCAN_PART.equals(scanPart)) {
                            break;
                        }
                    }
                }

                Plate plate;
                Integer plateId = null;

                if (f.getName().startsWith("STD_MEOH")) {
                    // The toffeStandard plate doesn't follow the usual naming convention, so we fake it here.
                    plate = Plate.getPlateByBarcode(db, "toffeeStandards");
                } else if (groupMap.containsKey(SCAN_NAME_COMPONENT.PLATE_BARCODE)) {
                    plate = Plate.getPlateByBarcode(db,
                            m.group((groupMap.get(SCAN_NAME_COMPONENT.PLATE_BARCODE))));
                } else if (groupMap.containsKey(SCAN_NAME_COMPONENT.PLATE_NAME)) {
                    plate = Plate.getPlateByName(db, m.group((groupMap.get(SCAN_NAME_COMPONENT.PLATE_NAME))));
                } else {
                    // The occurrence of this exception represents a developer oversight.
                    throw new RuntimeException(
                            String.format("No plate identifier available for pattern %s", p));
                }
                if (plate == null) {
                    System.err.format("WARNING: unable to find plate for scan file %s\n", f.getName());
                } else {
                    plateId = plate.getId();
                }

                Integer plateRow = null, plateColumn = null;
                if (groupMap.containsKey(SCAN_NAME_COMPONENT.ROW)) {
                    String plateRowStr = m.group(groupMap.get(SCAN_NAME_COMPONENT.ROW));
                    if (plateRowStr != null && !plateRowStr.isEmpty()) {
                        if (plateRowStr.length() > 1) {
                            // TODO: handle larger plates?
                            throw new RuntimeException(
                                    String.format("Unable to handle multi-character plate row %s for scan %s",
                                            plateRowStr, f.getName()));
                        }
                        plateRow = plateRowStr.charAt(0) - 'A';
                    }
                }

                if (groupMap.containsKey(SCAN_NAME_COMPONENT.COLUMN)) {
                    String plateColumnStr = m.group(groupMap.get(SCAN_NAME_COMPONENT.COLUMN));
                    if (plateColumnStr != null && !plateColumnStr.isEmpty()) {
                        plateColumn = Integer.parseInt(plateColumnStr) - 1; // Wells are one-indexed.
                    }
                }

                SCAN_MODE scanMode = SCAN_MODE.POS; // Assume positive scans by default.
                if (groupMap.containsKey(SCAN_NAME_COMPONENT.MODE)) {
                    String scanModeStr = m.group(groupMap.get(SCAN_NAME_COMPONENT.MODE));
                    if (scanModeStr != null && !scanModeStr.isEmpty()) {
                        scanMode = SCAN_MODE.valueOf(scanModeStr.toUpperCase());
                    }
                }

                SCAN_FILE_TYPE fileType = null;
                if (groupMap.containsKey(SCAN_NAME_COMPONENT.FILE_TYPE)) {
                    String fileTypeStr = m.group(groupMap.get(SCAN_NAME_COMPONENT.FILE_TYPE));
                    if (fileTypeStr != null && !fileTypeStr.isEmpty()) {
                        fileType = SCAN_FILE_TYPE.valueOf(fileTypeStr.toUpperCase());
                    }
                }

                ScanFile scanFile = getScanFileByFilename(db, f.getName());
                DB.OPERATION_PERFORMED op;
                if (scanFile == null) {
                    scanFile = insertScanFile(db, f.getName(), scanMode, fileType, plateId, plateRow,
                            plateColumn);
                    op = DB.OPERATION_PERFORMED.CREATE;
                } else {
                    scanFile.setFilename(f.getName());
                    scanFile.setMode(scanMode);
                    scanFile.setFileType(fileType);
                    scanFile.setPlateId(plateId);
                    scanFile.setPlateRow(plateRow);
                    scanFile.setPlateColumn(plateColumn);
                    updateScanFile(db, scanFile);
                    op = DB.OPERATION_PERFORMED.UPDATE;
                }

                // Should only be null if we can't insert the scanFile into the DB for some reason.
                if (scanFile == null) {
                    results.add(Pair.of((Integer) null, op));
                } else {
                    results.add(Pair.of(scanFile.getId(), op));
                }
                break;
            }
        }
    }
    return results;
}

From source file:com.google.dart.java2dart.engine.EngineSemanticProcessor.java

/**
 * Find code like://from  w  w w.  jav a2 s. c o  m
 * 
 * <pre>
 *   Field scopeField = visitor.getClass().getSuperclass().getDeclaredField("nameScope");
 *   scopeField.setAccessible(true);
 *   Scope outerScope = (Scope) scopeField.get(visitor);
 * </pre>
 * 
 * and replaces it with direct calling of generated public accessors.
 */
static void rewriteReflectionFieldsWithDirect(final Context context, CompilationUnit unit) {
    final Map<String, String> varToField = Maps.newHashMap();
    final Map<String, String> varToMethod = Maps.newHashMap();
    final Set<Pair<String, String>> refClassFields = Sets.newHashSet();
    final String accessorSuffix = "_J2DAccessor";
    unit.accept(new RecursiveASTVisitor<Void>() {

        @Override
        public Void visitBlock(Block node) {
            List<Statement> statements = ImmutableList.copyOf(node.getStatements());
            for (Statement statement : statements) {
                statement.accept(this);
            }
            return null;
        }

        @Override
        public Void visitExpressionStatement(ExpressionStatement node) {
            if (node.getExpression() instanceof MethodInvocation) {
                MethodInvocation invocation = (MethodInvocation) node.getExpression();
                if (JavaUtils.isMethod(context.getNodeBinding(invocation), "java.lang.reflect.AccessibleObject",
                        "setAccessible")) {
                    ((Block) node.getParent()).getStatements().remove(node);
                    return null;
                }
            }
            return super.visitExpressionStatement(node);
        }

        @Override
        public Void visitMethodInvocation(MethodInvocation node) {
            List<Expression> arguments = node.getArgumentList().getArguments();
            if (JavaUtils.isMethod(context.getNodeBinding(node), "java.lang.reflect.Field", "get")) {
                Expression target = arguments.get(0);
                String varName = ((SimpleIdentifier) node.getTarget()).getName();
                String fieldName = varToField.get(varName);
                String accessorName = fieldName + accessorSuffix;
                SemanticProcessor.replaceNode(node, propertyAccess(target, identifier(accessorName)));
                return null;
            }
            if (JavaUtils.isMethod(context.getNodeBinding(node), "java.lang.reflect.Field", "set")) {
                Expression target = arguments.get(0);
                String varName = ((SimpleIdentifier) node.getTarget()).getName();
                String fieldName = varToField.get(varName);
                String accessorName = fieldName + accessorSuffix;
                SemanticProcessor.replaceNode(node, assignmentExpression(
                        propertyAccess(target, identifier(accessorName)), TokenType.EQ, arguments.get(1)));
                return null;
            }
            if (JavaUtils.isMethod(context.getNodeBinding(node), "java.lang.reflect.Method", "invoke")) {
                Expression target = arguments.get(0);
                String varName = ((SimpleIdentifier) node.getTarget()).getName();
                String methodName = varToMethod.get(varName);
                List<Expression> methodArgs;
                if (arguments.size() == 1) {
                    methodArgs = Lists.newArrayList();
                } else if (arguments.size() == 2 && arguments.get(1) instanceof ListLiteral) {
                    methodArgs = ((ListLiteral) arguments.get(1)).getElements();
                } else {
                    methodArgs = Lists.newArrayList(arguments);
                    methodArgs.remove(0);
                }
                if (methodName != null) {
                    SemanticProcessor.replaceNode(node, methodInvocation(target, methodName, methodArgs));
                }
                return null;
            }
            return super.visitMethodInvocation(node);
        }

        @Override
        public Void visitVariableDeclarationStatement(VariableDeclarationStatement node) {
            super.visitVariableDeclarationStatement(node);
            VariableDeclarationList variableList = node.getVariables();
            ITypeBinding typeBinding = context.getNodeTypeBinding(variableList.getType());
            List<VariableDeclaration> variables = variableList.getVariables();
            if (JavaUtils.isTypeNamed(typeBinding, "java.lang.reflect.Field") && variables.size() == 1) {
                VariableDeclaration variable = variables.get(0);
                if (variable.getInitializer() instanceof MethodInvocation) {
                    MethodInvocation initializer = (MethodInvocation) variable.getInitializer();
                    if (JavaUtils.isMethod(context.getNodeBinding(initializer), "java.lang.Class",
                            "getDeclaredField")) {
                        Expression getFieldArgument = initializer.getArgumentList().getArguments().get(0);
                        String varName = variable.getName().getName();
                        String fieldName = ((SimpleStringLiteral) getFieldArgument).getValue();
                        varToField.put(varName, fieldName);
                        ((Block) node.getParent()).getStatements().remove(node);
                        // add (Class, Field) pair to generate accessor later
                        addClassFieldPair(initializer.getTarget(), fieldName);
                    }
                }
            }
            if (JavaUtils.isTypeNamed(typeBinding, "java.lang.reflect.Method") && variables.size() == 1) {
                VariableDeclaration variable = variables.get(0);
                if (variable.getInitializer() instanceof MethodInvocation) {
                    MethodInvocation initializer = (MethodInvocation) variable.getInitializer();
                    if (JavaUtils.isMethod(context.getNodeBinding(initializer), "java.lang.Class",
                            "getDeclaredMethod")) {
                        Expression getMethodArgument = initializer.getArgumentList().getArguments().get(0);
                        String varName = variable.getName().getName();
                        String methodName = ((SimpleStringLiteral) getMethodArgument).getValue();
                        varToMethod.put(varName, methodName);
                        ((Block) node.getParent()).getStatements().remove(node);
                    }
                }
            }
            return null;
        }

        private void addClassFieldPair(Expression target, String fieldName) {
            while (target instanceof MethodInvocation) {
                target = ((MethodInvocation) target).getTarget();
            }
            // we expect: object.runtimeType
            if (target instanceof PropertyAccess) {
                Expression classTarget = ((PropertyAccess) target).getTarget();
                ITypeBinding classTargetBinding = context.getNodeTypeBinding(classTarget);
                String className = classTargetBinding.getName();
                refClassFields.add(Pair.of(className, fieldName));
            }
        }
    });
    // generate private field accessors
    unit.accept(new RecursiveASTVisitor<Void>() {
        @Override
        public Void visitClassDeclaration(ClassDeclaration node) {
            String className = node.getName().getName();
            for (Pair<String, String> pair : refClassFields) {
                if (pair.getLeft().equals(className)) {
                    String fieldName = pair.getRight();
                    String accessorName = fieldName + accessorSuffix;
                    String privateFieldName = "_" + fieldName;
                    node.getMembers()
                            .add(methodDeclaration(null, null, Keyword.GET, null, identifier(accessorName),
                                    null, expressionFunctionBody(identifier(privateFieldName))));
                    node.getMembers()
                            .add(methodDeclaration(null, null, Keyword.SET, null, identifier(accessorName),
                                    formalParameterList(simpleFormalParameter("__v")),
                                    expressionFunctionBody(assignmentExpression(identifier(privateFieldName),
                                            TokenType.EQ, identifier("__v")))));
                }
            }
            return super.visitClassDeclaration(node);
        }
    });
}

From source file:com.act.lcms.db.analysis.PathwayProductAnalysis.java

private static Map<Integer, StandardWell> extractStandardWellsFromOptionsList(DB db,
        List<ChemicalAssociatedWithPathway> pathwayChems, String[] optionValues, Plate standardPlate)
        throws SQLException, IOException, ClassNotFoundException {
    Map<String, String> chemToWellByName = new HashMap<>();
    Map<Integer, String> chemToWellByIndex = new HashMap<>();
    if (optionValues != null && optionValues.length > 0) {
        for (int i = 0; i < optionValues.length; i++) {
            String[] fields = StringUtils.split(optionValues[i], "=");
            if (fields != null && fields.length == 2) {
                chemToWellByName.put(fields[0], fields[1]);
            } else {
                chemToWellByIndex.put(i, optionValues[i]);
            }/*from   w  ww . j  a v a 2s .c o m*/
        }
    }

    Map<Integer, StandardWell> results = new HashMap<>();
    for (int i = 0; i < pathwayChems.size(); i++) {
        ChemicalAssociatedWithPathway chem = pathwayChems.get(i);
        String coords = null;
        if (chemToWellByName.containsKey(chem.getChemical())) {
            coords = chemToWellByName.remove(chem.getChemical());
        } else if (chemToWellByIndex.containsKey(i)) {
            coords = chemToWellByIndex.remove(i);
        }

        if (coords == null) {
            System.err.format("No coordinates specified for %s, skipping\n", chem.getChemical());
            continue;
        }
        Pair<Integer, Integer> intCoords = Utils.parsePlateCoordinates(coords);
        StandardWell well = StandardWell.getInstance().getStandardWellsByPlateIdAndCoordinates(db,
                standardPlate.getId(), intCoords.getLeft(), intCoords.getRight());
        if (well == null) {
            System.err.format("ERROR: Could not find well %s in plate %s\n", coords,
                    standardPlate.getBarcode());
            System.exit(-1);
        } else if (!well.getChemical().equals(chem.getChemical())) {
            System.err.format(
                    "WARNING: pathway chemical %s and chemical in specified standard well %s don't match!\n",
                    chem.getChemical(), well.getChemical());
        }

        System.out.format("Using standard well %s : %s for pathway chemical %s (step %d)\n",
                standardPlate.getBarcode(), coords, chem.getChemical(), chem.getIndex());

        results.put(chem.getId(), well);
    }

    return results;
}

From source file:com.act.lcms.db.analysis.AnalysisHelper.java

private static Map<Pair<String, Double>, MS1ScanForWellAndMassCharge> getMultipleMS1s(MS1 ms1,
        Set<Pair<String, Double>> metlinMasses, String ms1File)
        throws ParserConfigurationException, IOException, XMLStreamException {

    // In order for this to sit well with the data model we'll need to ensure the keys are all unique.
    Set<String> uniqueKeys = new HashSet<>();
    metlinMasses.stream().map(Pair::getLeft).forEach(x -> {
        if (uniqueKeys.contains(x)) {
            throw new RuntimeException(
                    String.format("Assumption violation: found duplicate metlin mass keys: %s", x));
        }//from w  w  w  . j a v a 2  s  .com
        uniqueKeys.add(x);
    });

    Iterator<LCMSSpectrum> ms1Iterator = new LCMSNetCDFParser().getIterator(ms1File);

    Map<Double, List<XZ>> scanLists = new HashMap<>(metlinMasses.size());
    // Initialize reading buffers for all of the target masses.
    metlinMasses.forEach(x -> {
        if (!scanLists.containsKey(x.getRight())) {
            scanLists.put(x.getRight(), new ArrayList<>());
        }
    });
    // De-dupe by mass in case we have exact duplicates, sort for well-ordered extractions.
    List<Double> sortedMasses = new ArrayList<>(scanLists.keySet());

    /* Note: this operation is O(n * m) where n is the number of (mass, intensity) readings from the scan
     * and m is the number of mass targets specified.  We might be able to get this down to O(m log n), but
     * we'll save that for once we get this working at all. */

    while (ms1Iterator.hasNext()) {
        LCMSSpectrum timepoint = ms1Iterator.next();

        // get all (mz, intensity) at this timepoint
        List<Pair<Double, Double>> intensities = timepoint.getIntensities();

        // for this timepoint, extract each of the ion masses from the METLIN set
        for (Double ionMz : sortedMasses) {
            // this time point is valid to look at if its max intensity is around
            // the mass we care about. So lets first get the max peak location
            double intensityForMz = ms1.extractMZ(ionMz, intensities);

            // the above is Pair(mz_extracted, intensity), where mz_extracted = mz
            // we now add the timepoint val and the intensity to the output
            XZ intensityAtThisTime = new XZ(timepoint.getTimeVal(), intensityForMz);
            scanLists.get(ionMz).add(intensityAtThisTime);
        }
    }

    Map<Pair<String, Double>, MS1ScanForWellAndMassCharge> finalResults = new HashMap<>(metlinMasses.size());

    /* Note: we might be able to squeeze more performance out of this by computing the
     * stats once per trace and then storing them.  But the time to compute will probably
     * be dwarfed by the time to extract the data (assuming deduplication was done ahead
     * of time), so we'll leave it as is for now. */
    for (Pair<String, Double> pair : metlinMasses) {
        String label = pair.getLeft();
        Double mz = pair.getRight();
        MS1ScanForWellAndMassCharge result = new MS1ScanForWellAndMassCharge();

        result.setMetlinIons(Collections.singletonList(label));
        result.getIonsToSpectra().put(label, scanLists.get(mz));
        ms1.computeAndStorePeakProfile(result, label);

        // DO NOT use isGoodPeak here.  We want positive and negative results alike.

        // There's only one ion in this scan, so just use its max.
        Double maxIntensity = result.getMaxIntensityForIon(label);
        result.setMaxYAxis(maxIntensity);
        // How/why is this not IonsToMax?  Just set it as such for this.
        result.setIndividualMaxIntensities(Collections.singletonMap(label, maxIntensity));

        finalResults.put(pair, result);
    }

    return finalResults;
}

From source file:com.twitter.distributedlog.service.DistributedLogServer.java

static void closeServer(Pair<DistributedLogServiceImpl, Server> pair, long gracefulShutdownPeriod,
        TimeUnit timeUnit) {/*from w w w  . jav  a  2s .  com*/
    if (null != pair.getLeft()) {
        pair.getLeft().shutdown();
        if (gracefulShutdownPeriod > 0) {
            try {
                timeUnit.sleep(gracefulShutdownPeriod);
            } catch (InterruptedException e) {
                logger.info("Interrupted on waiting service shutting down state propagated to all clients : ",
                        e);
            }
        }
    }
    if (null != pair.getRight()) {
        logger.info("Closing dl thrift server.");
        pair.getRight().close();
        logger.info("Closed dl thrift server.");
    }
}