Example usage for java.lang Integer equals

List of usage examples for java.lang Integer equals

Introduction

In this page you can find the example usage for java.lang Integer equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:backend.facades.UserController.java

public UserEntity getUserByEmail(String email) {
    UserEntity userEntity = null;/*  w ww  .  ja  v  a  2s .  c o  m*/
    BasicDBObject query = new BasicDBObject();
    query.put("email", email);
    DBCursor cursor = userCollection.find(query);
    try {
        if (cursor.count() > 0) {
            DBObject document = cursor.next();
            userEntity = new UserEntity();
            userEntity.setId((Long) document.get("_id"));
            userEntity.setUsername((String) document.get("username"));
            userEntity.setEmail((String) document.get("email"));
            userEntity.setFirstname((String) document.get("firstname"));
            userEntity.setPasswd((String) document.get("passwd"));
            userEntity.setLastname((String) document.get("lastname"));
            userEntity.setStatus((Integer) document.get("status"));
            userEntity.setImageId((String) document.get("imageId"));
            userEntity.setRegisteredDate((Date) document.get("registeredDate"));
            userEntity.setLastLoginDate((Date) document.get("lastLoginDate"));
            userEntity.setLanguageCode((String) document.get("languageCode"));
            userEntity.setUserRole((Integer) document.get("userRole"));
            userEntity.setModeratorValue((Integer) document.get("moderator"));
            userEntity.setPersonalWebPage((String) document.get("webpage"));
            Integer value = (Integer) document.get("subscribe");
            if (value != null && value.equals(StatusTypes.ACCEPT_LICENSE)) {
                userEntity.setAcceptSubscr(true);
            } else {
                userEntity.setAcceptSubscr(false);
            }
        }
    } finally {
        cursor.close();
    }
    return userEntity;
}

From source file:backend.facades.UserController.java

public List<UserEntity> getSubscribersList() {
    UserEntity userEntity = null;/*  w ww  . j  a  va  2 s.com*/
    List<UserEntity> userList = new ArrayList<UserEntity>();
    BasicDBObject query = new BasicDBObject();
    query.put("subscribe", StatusTypes.ACCEPT_SUBSCRB);
    DBCursor cursor = userCollection.find(query);
    try {
        while (cursor.hasNext()) {
            DBObject document = cursor.next();
            userEntity = new UserEntity();
            userEntity.setId((Long) document.get("_id"));
            userEntity.setUsername((String) document.get("username"));
            userEntity.setEmail((String) document.get("email"));
            userEntity.setFirstname((String) document.get("firstname"));
            userEntity.setPasswd((String) document.get("passwd"));
            userEntity.setLastname((String) document.get("lastname"));
            userEntity.setStatus((Integer) document.get("status"));
            userEntity.setImageId((String) document.get("imageId"));
            userEntity.setRegisteredDate((Date) document.get("registeredDate"));
            userEntity.setLastLoginDate((Date) document.get("lastLoginDate"));
            userEntity.setLanguageCode((String) document.get("languageCode"));
            userEntity.setUserRole((Integer) document.get("userRole"));
            userEntity.setModeratorValue((Integer) document.get("moderator"));
            userEntity.setPersonalWebPage((String) document.get("webpage"));
            Integer value = (Integer) document.get("subscribe");
            if (value != null && value.equals(StatusTypes.ACCEPT_LICENSE)) {
                userEntity.setAcceptSubscr(true);
            } else {
                userEntity.setAcceptSubscr(false);
            }
            userList.add(userEntity);
        }
    } finally {
        cursor.close();
    }
    return userList;
}

From source file:eu.smartenit.unada.tpm.TopologyProximityMonitorImpl.java

@Override
public List<Integer> getASVector(UnadaInfo info)
        throws UnknownHostException, IOException, InterruptedException {
    logger.debug("Getting AS vector for {}", info.getInetAddress().getHostAddress());
    List<Inet4Address> hops = parseTraceroute(executeTraceroute((Inet4Address) info.getInetAddress()));

    Map<Inet4Address, Integer> ipToASN = new TeamCymruWhoisClient(TEAM_CYMRU_WHOIS_HOST,
            RESOLVE_SPECIAL_PURPOSE_ADDRESSES).ipToASN(hops); // new TeamCymruWhoisClient instance for each request

    List<Integer> asvector = new ArrayList<>();
    Integer lastAS = null;//from   w w w  .  jav  a  2s  .c o m
    int nulls = 0;
    for (Inet4Address hop : hops) {
        Integer as = ipToASN.get(hop);
        if (as != null && as.equals(lastAS)) {
            // within the same AS
            nulls = 0;
        } else if (as != null) {
            // unkown intermediate ASes
            for (int i = 0; i < nulls; i++) {
                asvector.add(null);
            }

            // another AS
            asvector.add(as);
            lastAS = as;
        } else {
            nulls = COMPACT_NULL_HOPS ? 1 : nulls + 1; // same or another AS?
        }
    }
    // unkown ASes
    for (int i = 0; i < nulls; i++) {
        asvector.add(null);
    }
    return asvector;
}

From source file:com.evolveum.midpoint.web.page.admin.configuration.PageImportObject.java

private void addVisibileForInputType(Component comp, final Integer type, final IModel<Integer> groupModel) {
    comp.add(new VisibleEnableBehaviour() {

        @Override//from  w w  w.  ja va2  s .c  o  m
        public boolean isVisible() {
            return type.equals(groupModel.getObject());
        }

    });
}

From source file:com.eryansky.modules.sys.service.OrganManager.java

/**
 * OrganTreeNode/*w  w w  . j av a  2  s.  c  om*/
 * @param organ 
 * @param organType 
 * @param isCascade       ??
 * @return
 * @throws com.eryansky.common.exception.DaoException
 * @throws com.eryansky.common.exception.SystemException
 * @throws com.eryansky.common.exception.ServiceException
 */
private TreeNode organToTreeNode(Organ organ, Integer organType, boolean isCascade)
        throws DaoException, SystemException, ServiceException {
    if (organType != null) {
        if (!organType.equals(organ.getType())) {
            return null;
        }
    }
    TreeNode treeNode = new TreeNode(organ.getId().toString(), organ.getName());
    //  url
    Map<String, Object> attributes = Maps.newHashMap();
    attributes.put("code", organ.getCode());
    attributes.put("type", organ.getType());
    treeNode.setAttributes(attributes);
    if (isCascade) {
        List<TreeNode> childrenTreeNodes = Lists.newArrayList();
        for (Organ subOrgan : organ.getSubOrgans()) {
            TreeNode node = organToTreeNode(subOrgan, organType, isCascade);
            if (node != null) {
                childrenTreeNodes.add(node);
            }
        }
        treeNode.setChildren(childrenTreeNodes);
    }

    return treeNode;
}

From source file:com.excilys.ebi.bank.service.impl.BankServiceImpl.java

@Override
@Transactional(readOnly = false)/*from   w ww .  j av a 2  s. com*/
public void performTransfer(Integer debitedAccountId, Integer creditedAccountId, @Min(10) BigDecimal amount)
        throws UnsufficientBalanceException {

    isTrue(!debitedAccountId.equals(creditedAccountId), "accounts must be different");

    Account debitedAccount = accountDao.findOne(debitedAccountId);
    notNull(debitedAccount, "account with number {} not found", debitedAccount);

    if (debitedAccount.getBalance().compareTo(amount) < 0) {
        throw new UnsufficientBalanceException();
    }

    Account creditedAccount = accountDao.findOne(creditedAccountId);
    notNull(creditedAccount, "account with number {} not found", creditedAccount);

    debitedAccount.setBalance(debitedAccount.getBalance().subtract(amount));
    creditedAccount.setBalance(creditedAccount.getBalance().add(amount));

    DateTime now = now();
    OperationStatusRef status = operationStatusDao.findOne(OperationStatus.RESOLVED);
    OperationTypeRef type = operationTypeDao.findOne(OperationType.TRANSFER);

    Operation debitOperation = newOperation().withName("transfert -" + amount).withAccount(debitedAccount)
            .withAmount(amount.negate()).withDate(now).withStatus(status).withType(type).build();
    Operation creditOperation = newOperation().withName("transfert +" + amount).withAccount(creditedAccount)
            .withAmount(amount).withDate(now).withStatus(status).withType(type).build();

    operationDao.save(debitOperation);
    operationDao.save(creditOperation);
}

From source file:de.ingrid.importer.udk.strategy.v1.IDCStrategy1_0_5_fixCountryCodelist.java

private void updateSysList() throws Exception {
    if (log.isInfoEnabled()) {
        log.info("Updating sys_list...");
    }//from w  ww .j a  va 2 s . c  om

    // ---------------------------------------------

    if (log.isInfoEnabled()) {
        log.info("Updating syslist " + UtilsCountryCodelist.COUNTRY_SYSLIST_ID + " Country ...");
    }

    // clean up, to guarantee no old values !
    sqlStr = "DELETE FROM sys_list where lst_id = " + UtilsCountryCodelist.COUNTRY_SYSLIST_ID;
    jdbc.executeUpdate(sqlStr);

    pSqlStr = "INSERT INTO sys_list (id, lst_id, entry_id, lang_id, name, maintainable, is_default) "
            + "VALUES ( ?, " + UtilsCountryCodelist.COUNTRY_SYSLIST_ID + ", ?, ?, ?, 0, ?)";

    PreparedStatement pS = jdbc.prepareStatement(pSqlStr);

    Iterator<Integer> itr = UtilsCountryCodelist.countryCodelist_de.keySet().iterator();
    while (itr.hasNext()) {
        Integer key = itr.next();

        // german version
        int cnt = 1;
        pS.setLong(cnt++, getNextId()); // id
        pS.setInt(cnt++, key); // entry_id
        pS.setString(cnt++, "de"); // lang_id
        pS.setString(cnt++, UtilsCountryCodelist.countryCodelist_de.get(key)); // name
        pS.setString(cnt++, (key.equals(UtilsCountryCodelist.COUNTRY_KEY_GERMANY)) ? "Y" : "N"); // is_default
        pS.executeUpdate();

        // english version
        cnt = 1;
        pS.setLong(cnt++, getNextId()); // id
        pS.setInt(cnt++, key); // entry_id
        pS.setString(cnt++, "en"); // lang_id
        pS.setString(cnt++, UtilsCountryCodelist.countryCodelist_en.get(key)); // name
        pS.setString(cnt++, (key.equals(UtilsCountryCodelist.COUNTRY_KEY_GBR)) ? "Y" : "N"); // is_default
        pS.executeUpdate();
    }

    pS.close();

    if (log.isInfoEnabled()) {
        log.info("Updating sys_list... done");
    }
}

From source file:com.gst.portfolio.charge.serialization.ChargeDefinitionCommandFromApiJsonDeserializer.java

private void performChargeTimeNCalculationTypeValidation(DataValidatorBuilder baseDataValidator,
        final Integer chargeTimeType, final Integer chargeCalculationType) {
    if (chargeTimeType.equals(ChargeTimeType.SHAREACCOUNT_ACTIVATION.getValue())) {
        baseDataValidator.reset().parameter("chargeCalculationType").value(chargeCalculationType)
                .isOneOfTheseValues(ChargeCalculationType.validValuesForShareAccountActivation());
    }/* w w w  . j a v  a  2 s.  c o  m*/

    if (chargeTimeType.equals(ChargeTimeType.TRANCHE_DISBURSEMENT.getValue())) {
        baseDataValidator.reset().parameter("chargeCalculationType").value(chargeCalculationType)
                .isOneOfTheseValues(ChargeCalculationType.validValuesForTrancheDisbursement());
    } else {
        baseDataValidator.reset().parameter("chargeCalculationType").value(chargeCalculationType)
                .isNotOneOfTheseValues(ChargeCalculationType.PERCENT_OF_DISBURSEMENT_AMOUNT.getValue());
    }
}

From source file:org.jasig.portlet.courses.mvc.wrapper.CourseSectionWrapper.java

/**
 * @param dayId the dayId to set//from  w  w w.  j a  va 2  s  .  c om
 */
public void setDayId(Integer dayId) {
    this.dayId = dayId.equals(new Integer(7)) ? new Integer(0) : dayId;
    this.scheduledDay = this.dayId;
}

From source file:eu.sisob.uma.restserver.services.gate.GateDataExtractorTaskInRest.java

public void executeTask() {

    File results_data_dir = new File(task_code_folder + File.separator + AuthorizationManager.results_dirname);

    for (MiddleData md : this.taskRepPrePro.getMiddleDataList()) {
        HashMap<String, String> extra_data = null;
        try {//from  w  ww.  ja va 2  s .  co  m
            extra_data = (HashMap<String, String>) md.getData_extra();
            Integer block_type = Integer
                    .parseInt(extra_data.get(DataExchangeLiterals.MIDDLE_ELEMENT_XML_EXTRADATA_BLOCK_TYPE));
            if (block_type != null) {

                String desc = CVBlocks.CVBLOCK_DESCRIPTIONS[block_type];
                if (block_type.equals(CVBlocks.CVBLOCK_PUBLICATIONS)
                        || block_type.equals(CVBlocks.CVBLOCK_PROFESSIONAL_ACTIVITY)
                        || block_type.equals(CVBlocks.CVBLOCK_UNIVERSITY_STUDIES)) {

                    String separator = "\n";
                    if (md.getData_in().toString().contains("\r\n"))
                        separator = "\r\n";
                    String data = md.getData_in().toString();
                    String[] lines = null;
                    if (data.startsWith("http") || data.startsWith("file")) {
                        URL url = new URL(data);
                        Document doc = Factory.newDocument(url);
                        lines = doc.getContent().toString().split(separator);
                    } else {
                        lines = md.getData_in().toString().split(separator);
                    }

                    for (int i = 0; i < lines.length; i++) {
                        FileUtils.write(new File(results_data_dir, desc + "-lines.csv"), "\""
                                + md.getId_entity() + "\",\"" + lines[i].replace("\"", "'") + "\"" + "\r\n",
                                true);
                    }
                }
            }

        } catch (Exception ex) {
            extra_data = null;
        }
    }

    super.executeTask();
}