Example usage for java.lang Long intValue

List of usage examples for java.lang Long intValue

Introduction

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

Prototype

public int intValue() 

Source Link

Document

Returns the value of this Long as an int after a narrowing primitive conversion.

Usage

From source file:net.bitnine.agensgraph.graph.property.JsonObject.java

public Integer getInt(String name) {
    Long value = getLong(name);
    return (value == null) ? null : value.intValue();
}

From source file:gate.corpora.DocumentContentImpl.java

/** Propagate changes to the document content. */
void edit(Long start, Long end, DocumentContent replacement) {
    int s = start.intValue(), e = end.intValue();
    String repl = replacement == null ? "" : ((DocumentContentImpl) replacement).content;
    StringBuffer newContent = new StringBuffer(content);
    newContent.replace(s, e, repl);/*from  w  w w .  j  a v a  2 s  .c  o  m*/
    content = newContent.toString();
}

From source file:com.wizecommerce.hecuba.JSONResultSet.java

public Integer getInteger(String fieldName, Integer defaultInt) {

    Long value = (Long) decoder.get(fieldName);

    return (value == null) ? defaultInt : value.intValue();
}

From source file:reviewbot.service.BookService.java

@Override
public BookDTO readOne(Long id) {
    return unwrap(_bookRepository.readOne(id.intValue()));
}

From source file:com.sangupta.dryrun.redis.OpsForValue.java

@Override
public void set(K key, V value, long timeout, TimeUnit unit) {
    if (TimeUnit.MILLISECONDS.equals(unit)) {
        int millis = ((Long) timeout).intValue();
        this.bridge.psetex(rawKey(key), millis, rawValue(value));
        return;//from  w  w w.j  ava2 s.c  o  m
    }

    Long seconds = unit.toSeconds(timeout);
    this.bridge.setex(rawKey(key), seconds.intValue(), rawValue(value));
}

From source file:mx.edu.um.mateo.rh.dao.impl.PuestoDaoHibernate.java

@Override
public Map<String, Object> lista(Map<String, Object> params) {
    log.debug("Buscando lista de puestos con params {}", params);
    if (params == null) {
        params = new HashMap<>();
    }//from  ww  w  . j  ava  2s.  c  om

    if (!params.containsKey("max")) {
        params.put("max", 10);
    } else {
        params.put("max", Math.min((Integer) params.get("max"), 100));
    }

    if (params.containsKey("pagina")) {
        Long pagina = (Long) params.get("pagina");
        Long offset = (pagina - 1) * (Integer) params.get("max");
        params.put("offset", offset.intValue());
    }

    if (!params.containsKey("offset")) {
        params.put("offset", 0);
    }
    Criteria criteria = currentSession().createCriteria(Puesto.class);
    Criteria countCriteria = currentSession().createCriteria(Puesto.class);

    if (params.containsKey("empresa")) {
        criteria.createCriteria("empresa").add(Restrictions.idEq(params.get("empresa")));
        countCriteria.createCriteria("empresa").add(Restrictions.idEq(params.get("empresa")));
    }

    if (params.containsKey("filtro")) {
        String filtro = (String) params.get("filtro");
        Disjunction propiedades = Restrictions.disjunction();
        propiedades.add(Restrictions.ilike("nombre", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("nombreCompleto", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("rfc", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("correo", filtro, MatchMode.ANYWHERE));
        propiedades.add(Restrictions.ilike("contacto", filtro, MatchMode.ANYWHERE));
        criteria.add(propiedades);
        countCriteria.add(propiedades);
    }

    if (params.containsKey("order")) {
        String campo = (String) params.get("order");
        if (params.get("sort").equals("desc")) {
            criteria.addOrder(Order.desc(campo));
        } else {
            criteria.addOrder(Order.asc(campo));
        }
    }

    if (!params.containsKey("reporte")) {
        criteria.setFirstResult((Integer) params.get("offset"));
        criteria.setMaxResults((Integer) params.get("max"));
    }
    params.put(Constants.PUESTO_LIST, criteria.list());

    countCriteria.setProjection(Projections.rowCount());
    params.put("cantidad", (Long) countCriteria.list().get(0));

    return params;
}

From source file:org.springsource.restbucks.order.OrderRepositoryIntegrationTest.java

@Test
public void createsNewOrder() {

    Long before = repository.count();

    Order order = repository.save(createOrder());

    Iterable<Order> result = repository.findAll();
    assertThat(result, is(Matchers.<Order>iterableWithSize(before.intValue() + 1)));
    assertThat(result, hasItem(order));// w  w w.java2 s.c o m
}

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

@RequestMapping("/list")
public ModelAndView list(@Valid ProjectListRequest request, BindingResult result) {
    ModelAndView mv = createModelView(DEMAND_LIST, request);
    PageQuery query = request.init().getQuery();
    DemandCriteria criteria = new DemandCriteria();
    criteria.setLimit(query.getPage_size());
    criteria.setOffset(query.getIndex());
    criteria.setStatus(new String[] { request.getStatus() });
    criteria.setProjectName(request.getName());
    criteria.setUserId(request.getId());
    criteria.setBeused((byte) 2);
    List<Demand> list = demandDAO.queryDemand(criteria);
    Long count = demandDAO.countDemand(criteria);
    query.setCount((count == null || count <= 0L) ? 0 : count.intValue());
    mv.addObject("query", query);
    mv.addObject("demandList", list);
    mv.addObject("success", CollectionUtils.isNotEmpty(list));
    mv.addObject("req", request);
    return mv;//from w  w w.  ja v  a2s.  co  m
}

From source file:org.jason.mapmaker.repository.impl.HibernateGenericRepository.java

@SuppressWarnings("unchecked")
public T get(Long id) {

    return (T) sessionFactory.getCurrentSession().get(clazz, id.intValue());
}

From source file:com.google.gwt.sample.dynatablemvp.server.svc.SchoolCalendarService.java

public Person getRandomPerson() {
    Long countAll = personService.countAll();
    if (countAll == null)
        return null;
    return getPeople(null, new Random().nextInt(countAll.intValue()), 1, WeekDayStorage.ALL_DAYS).get(0);
}