Example usage for java.lang Long valueOf

List of usage examples for java.lang Long valueOf

Introduction

In this page you can find the example usage for java.lang Long valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Long valueOf(long l) 

Source Link

Document

Returns a Long instance representing the specified long value.

Usage

From source file:com.google.code.stackexchange.client.examples.QuestionsApiExample.java

/**
 * Process command line.//from   ww  w. j  a  v a  2s. co m
 * 
 * @param line the line
 * @param options the options
 */
private static void processCommandLine(CommandLine line, Options options) {
    if (line.hasOption(HELP_OPTION)) {
        printHelp(options);
    } else if (line.hasOption(APPLICATION_KEY_OPTION)) {
        final String keyValue = line.getOptionValue(APPLICATION_KEY_OPTION);

        final StackExchangeApiClientFactory factory = StackExchangeApiClientFactory.newInstance(keyValue);
        final StackExchangeApiClient client = factory.createStackExchangeApiClient();

        if (line.hasOption(ID_OPTION)) {
            String idValue = line.getOptionValue(ID_OPTION);
            List<Question> question = client.getQuestions(Long.valueOf(idValue));
            printResult(question.get(0));
        } else {
            List<Question> questions = client
                    .getQuestions(EnumSet.of(FilterOption.INCLUDE_BODY, FilterOption.INCLUDE_COMMENTS));
            for (Question question : questions) {
                printResult(question);
            }

            List<PostTimeline> questionTimeline = client.getQuestionsTimeline(2420689L);
            for (PostTimeline timeline : questionTimeline) {
                printResult(timeline);
            }
        }
    } else {
        printHelp(options);
    }
}

From source file:cz.muni.fi.mir.db.service.impl.UserRoleServiceImpl.java

@Override
@Transactional(readOnly = true)//ww  w  .jav a  2  s.c  om
public UserRole getUserRoleByID(Long id) throws IllegalArgumentException {
    if (id == null || Long.valueOf("0").compareTo(id) >= 0) {
        throw new IllegalArgumentException(
                "Given entity does not have valid id should be greater than one but was [" + id + "]");
    }

    return userRoleDAO.getByID(id);
}

From source file:de.hybris.platform.b2b.punchout.services.CXMLBuilder.java

/**
 * Generates a new payload ID in the required format: datetime.process id.random number@hostname. Note: Process ID is
 * skipped as there's no easy way to get it.
 * /*ww  w . ja  v a  2  s. c o m*/
 * @return the payload ID
 */
private String generatePayload() {
    return String.format("%s.%s@%s", Long.valueOf(new DateTime().getMillis()),
            Integer.valueOf(RandomUtils.nextInt(RANDOM_INT_LIMIT)), findHostName());
}

From source file:com.consol.citrus.admin.service.report.JUnitTestReportService.java

@Override
public TestReport getLatest(Project activeProject) {
    TestReport report = new TestReport();

    if (hasTestResults(activeProject)) {
        try {/*w  w  w.  j  av  a  2  s . c o m*/
            Document testResults = XMLUtils.parseMessagePayload(getTestResultsAsString(activeProject));
            report.setSuiteName(XPathUtils.evaluateAsString(testResults, "/testsuite/@name", null));
            report.setDuration(Math.round(
                    Double.valueOf(XPathUtils.evaluateAsString(testResults, "/testsuite/@time", null)) * 1000));

            report.setFailed(
                    Long.valueOf(XPathUtils.evaluateAsString(testResults, "/testsuite/@failures", null)));
            report.setSkipped(
                    Long.valueOf(XPathUtils.evaluateAsString(testResults, "/testsuite/@skipped", null)));
            report.setTotal(Long.valueOf(XPathUtils.evaluateAsString(testResults, "/testsuite/@tests", null)));
            report.setPassed(report.getTotal() - report.getSkipped() - report.getFailed());
        } catch (IOException e) {
            log.error("Failed to read test results file", e);
        }
    }

    return report;
}

From source file:ch.cern.db.flume.sink.elasticsearch.TimestampedEvent.java

TimestampedEvent(Event base) {
    setBody(base.getBody());//from  www  . j av a 2 s  .  c o m
    Map<String, String> headers = Maps.newHashMap(base.getHeaders());
    String timestampString = headers.get("timestamp");
    if (StringUtils.isBlank(timestampString)) {
        timestampString = headers.get("@timestamp");
    }
    if (StringUtils.isBlank(timestampString)) {
        this.timestamp = DateTimeUtils.currentTimeMillis();
        headers.put("timestamp", String.valueOf(timestamp));
    } else {
        this.timestamp = Long.valueOf(timestampString);
    }
    setHeaders(headers);
}

From source file:com.aalto.controllers.ProjectController.java

@RequestMapping(value = "/getProjectByPid/{pidString}", method = RequestMethod.GET)
public Project getProjectByPid(@PathVariable String pidString) {
    logger.log(Level.INFO, "log: ProjectController getProjectByPid !!");
    Long pid = Long.valueOf(pidString);
    Project project = this.projectRepo.find(pid);
    return project;
}

From source file:net.sf.jabb.util.stat.AtomicLongStatistics.java

@Override
public boolean equals(Object other) {
    if (other == this) {
        return true;
    }/*from  w w  w  . jav a  2 s  .c  o  m*/
    if (other == null || !(other instanceof NumberStatistics<?>)) {
        return false;
    }
    NumberStatistics<?> that = (NumberStatistics<?>) other;
    return new EqualsBuilder().append(this.getCount(), that.getCount())
            .append(this.getSum(), that.getSum() == null ? null : Long.valueOf(that.getSum().longValue()))
            .append(this.getMin(), that.getMin() == null ? null : Long.valueOf(that.getMin().longValue()))
            .append(this.getMax(), that.getMax() == null ? null : Long.valueOf(that.getMax().longValue()))
            .isEquals();
}

From source file:com.insoul.ti.controller.ContestEntryController.java

@RequestMapping("/list")
public ModelAndView list(@Valid ContestEntryListRequest request, BindingResult result) {
    ModelAndView mv = createModelView(CONTEST_ENTRY_LIST, request);
    PageQuery query = request.init().getQuery();
    ContestEntryCriteria criteria = new ContestEntryCriteria();
    criteria.setLimit(query.getPage_size());
    criteria.setOffset(Long.valueOf(query.getIndex()).intValue());
    criteria.setContestId(request.getContestId());
    criteria.setUserId(request.getUserId());
    List<ContestEntry> list = contestEntryDAO.queryContestEntry(criteria);
    Long count = contestEntryDAO.countContestEntry(criteria);
    query.setCount((count == null || count <= 0L) ? 0 : count.intValue());
    List<ContestEntryVO> voList = new ArrayList<ContestEntryVO>();
    if (CollectionUtils.isNotEmpty(list)) {
        for (ContestEntry contestEntry : list) {
            voList.add(toContestEntryVO(contestEntry));
        }/*from   ww w .j  a  v a  2s . c  om*/
        mv.addObject("query", query);
        mv.addObject("contestEntryList", voList);
        mv.addObject("success", true);
        mv.addObject("req", request);
        return mv;
    }
    mv.addObject("query", query);
    mv.addObject("contestEntryList", voList);
    mv.addObject("success", false);
    mv.addObject("req", request);
    return mv;
}

From source file:com.baidubce.http.BceHttpResponse.java

public long getHeaderAsLong(String name) {
    String value = this.getHeader(name);
    if (value == null) {
        return -1;
    }//from w  ww  .j  a va  2s . c o m
    try {
        return Long.valueOf(value);
    } catch (Exception e) {
        logger.warn("Invalid " + name + ":" + value, e);
        return -1;
    }
}

From source file:cz.muni.fi.mir.db.service.impl.SourceDocumentServiceImpl.java

@Override
@Transactional(readOnly = true)//from w  w w.j a  va 2 s. c  om
public SourceDocument getSourceDocumentByID(Long id) {
    if (id == null || Long.valueOf("0").compareTo(id) >= 0) {
        throw new IllegalArgumentException(
                "Given entity does not have valid id should be greater than one but was [" + id + "]");
    }

    return sourceDocumentDAO.getByID(id);
}