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.albert.util.StringUtilCommon.java

/**
 * convert string to Long./*  ww  w .j a  va2 s.co m*/
 * 
 * @param str
 * @return Long
 */
public static Long toLong(String str) {
    Long outInteger = null;
    if (!isEmpty(str)) {
        outInteger = Long.valueOf(str);
    }
    return outInteger;
}

From source file:dao.jpa.JpaUtilsTest.java

@Test
@Transactional//from  ww  w .jav a  2  s  .co m
public void testCountFromCriteria() {
    CriteriaBuilder cb = em.getCriteriaBuilder();
    CriteriaQuery<Book> bookQuery = cb.createQuery(Book.class);
    Root<Book> root = bookQuery.from(Book.class);
    bookQuery.where(cb.equal(JpaUtils.getPath(root, "author.name"), "Rod"));
    CriteriaQuery<Long> countQuery = JpaUtils.countCriteria(em, bookQuery);
    Long result = Long.valueOf(em.createQuery(bookQuery).getResultList().size());

    assertEquals(result, (Long) em.createQuery(countQuery).getSingleResult());

}

From source file:com.doculibre.constellio.wicket.panels.results.IntelliGIDSearchResultPanel.java

public IntelliGIDSearchResultPanel(String id, SolrDocument doc, final SearchResultsDataProvider dataProvider) {
    super(id, doc, dataProvider);

    String contentLength = (String) doc.getFieldValue("contentLength");
    String type = (String) doc.getFieldValue("subType");

    String contentLengthKBStr;/* w ww . j  a  va  2 s  . co m*/
    if (StringUtils.isNotBlank(contentLength)) {
        long contentLengthBytes;
        try {
            contentLengthBytes = Long.valueOf(contentLength);
        } catch (NumberFormatException e) {
            contentLengthBytes = -1;
        }
        double contentLengthKB = (double) contentLengthBytes / 1000;
        DecimalFormat contentLengthKBFormatter = new DecimalFormat();
        contentLengthKBFormatter.setMinimumFractionDigits(0);
        contentLengthKBFormatter.setMaximumFractionDigits(0);
        contentLengthKBStr = contentLengthKBFormatter.format(contentLengthKB);
        if ("0".equals(contentLengthKBStr)) {
            contentLengthKBStr = null;
        }
    } else {
        contentLengthKBStr = null;
    }

    add(new Label("contentLength", contentLengthKBStr + " KB").setVisible(contentLengthKBStr != null));
    add(new Label("type", type).setVisible(StringUtils.isNotBlank(type)));

}

From source file:cz.muni.fi.editor.test.service.organization.OrganizationServiceGetIdIT.java

@Test(expected = AccessDeniedException.class)
@WithEditorUser
public void getNotExists() {
    organizationService.getById(Long.valueOf(1000L));
}

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

@Override
public Annotation getAnnotationByID(Long id) throws IllegalArgumentException {
    if (id == null) {
        throw new IllegalArgumentException("Given id is null");
    }// w  ww  .j  ava  2 s .com
    if (Long.valueOf("0").compareTo(id) >= 0) {
        throw new IllegalArgumentException(
                "Given id is out of valid range. Should be greater than 0 and is [" + id + "]");
    }

    return annotationDAO.getByID(id);
}

From source file:com.tesora.dve.distribution.ColumnDatum.java

public static Comparable<?> getValueForComparison(IColumnDatum col, Object value) {
    Comparable<?> valueForCompare = (Comparable<?>) value;
    if (MysqlNativeType.MysqlType.DATETIME.toString().equals(col.getNativeType())) {
        if (value instanceof String) {
            valueForCompare = (Comparable<?>) Singletons.require(DBNative.class).getValueConverter().convert(
                    (String) value,
                    BasicType.getDateTimeType(Singletons.require(DBNative.class).getTypeCatalog()));
        }/*from www .j a  v  a  2 s  .co m*/
    } else {
        if (value instanceof Integer)
            valueForCompare = new Long(Long.valueOf(((Integer) value).longValue()));
        else if (value instanceof Short)
            valueForCompare = new Long(Long.valueOf(((Short) value).longValue()));
        else if (value instanceof Byte)
            valueForCompare = new Long(Long.valueOf(((Byte) value).longValue()));
    }
    return valueForCompare;
}

From source file:com.jslsolucoes.tagria.doc.repository.impl.PessoaRepositoryImpl.java

public PessoaRepositoryImpl() {
    pessoas = new ArrayList<Pessoa>();
    for (int i = 1; i <= 10; i++) {
        Pessoa pessoa = new Pessoa();
        pessoa.setNome(RandomStringUtils.randomAlphabetic(10));
        pessoa.setDataNascimento(Calendar.getInstance().getTime());
        pessoa.setGostaChocolate((i % 2 == 0 ? 1 : 0));
        pessoa.setCpf(RandomStringUtils.randomNumeric(11));
        pessoa.setCep(RandomStringUtils.randomNumeric(8));
        pessoa.setId(Long.valueOf(i));
        pessoas.add(pessoa);//  w w  w.  j  av  a  2 s  .c  om
    }

}

From source file:com.glaf.shiro.SecurityConfig.java

public static long getLong(String key) {
    if (hasObject(key)) {
        String value = filterChainDefinitionMap.get(key);
        return Long.valueOf(value).longValue();
    }/*from  w w w. j  a v  a  2  s .c o m*/
    return 0;
}

From source file:org.web4thejob.orm.DataReaderServiceTest.java

@Test
public void findFirstByQuery() {
    final Master1 master1 = ContextUtil.getDRS().get(Master1.class, Long.valueOf(iterations));
    Assert.assertNotNull(master1);/* w w w.  ja va  2  s  . c  o  m*/

    final Query query = ContextUtil.getEntityFactory().buildQuery(Master1.class);
    query.addOrderBy(new Path(ContextUtil.getMRS().getEntityMetadata(Master1.class).getIdentifierName()), true);

    Assert.assertEquals(master1, ContextUtil.getDRS().findFirstByQuery(query));
}

From source file:com.hybris.integration.service.tmall.impl.ProductServiceImpl.java

@Override
public ItemUpdateDelistingResponse deListing(String integrationId, String productId)
        throws TmallAppException, ApiException {
    LOGGER.info("Product {" + integrationId + "} delist starting...");
    ItemUpdateDelistingRequest request = new ItemUpdateDelistingRequest();
    request.setNumIid(Long.valueOf(productId));
    final ItemUpdateDelistingResponse response = getClient(integrationId).execute(request,
            getToken(integrationId));//from w  ww  . j a  v  a  2 s. c o  m
    if (response != null && StringUtils.isEmpty(response.getErrorCode())) {
        LOGGER.info("Product {" + productId + "} delist finished successfully...");
    } else {
        LOGGER.error("Tmall API item.update.delisting failed request:" + response.getBody());
        LOGGER.error("Product {" + productId + "} delist failure...");
        throw new TmallAppException(ResponseCode.REQUEST_TMALL_ERROR.getCode(), response.getSubMsg());
    }
    return response;
}