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:com.datatorrent.contrib.kafka.AbstractKafkaInputOperator.java

protected void replay(long windowId) {
    try {//from ww w . java  2  s.  c o m
        @SuppressWarnings("unchecked")
        Map<KafkaPartition, MutablePair<Long, Integer>> recoveredData = (Map<KafkaPartition, MutablePair<Long, Integer>>) windowDataManager
                .retrieve(windowId);
        if (recoveredData != null) {
            Map<String, List<PartitionMetadata>> pms = KafkaMetadataUtil
                    .getPartitionsForTopic(getConsumer().brokers, getConsumer().topic);
            if (pms != null) {
                SimpleKafkaConsumer cons = (SimpleKafkaConsumer) getConsumer();
                // add all partition request in one Fretch request together
                FetchRequestBuilder frb = new FetchRequestBuilder().clientId(cons.getClientId());
                for (Map.Entry<KafkaPartition, MutablePair<Long, Integer>> rc : recoveredData.entrySet()) {
                    KafkaPartition kp = rc.getKey();
                    List<PartitionMetadata> pmsVal = pms.get(kp.getClusterId());

                    Iterator<PartitionMetadata> pmIterator = pmsVal.iterator();
                    PartitionMetadata pm = pmIterator.next();
                    while (pm.partitionId() != kp.getPartitionId()) {
                        if (!pmIterator.hasNext())
                            break;
                        pm = pmIterator.next();
                    }
                    if (pm.partitionId() != kp.getPartitionId())
                        continue;

                    Broker bk = pm.leader();

                    frb.addFetch(consumer.topic, rc.getKey().getPartitionId(), rc.getValue().left,
                            cons.getBufferSize());
                    FetchRequest req = frb.build();

                    SimpleConsumer ksc = new SimpleConsumer(bk.host(), bk.port(), cons.getTimeout(),
                            cons.getBufferSize(), cons.getClientId());
                    FetchResponse fetchResponse = ksc.fetch(req);
                    Integer count = 0;
                    for (MessageAndOffset msg : fetchResponse.messageSet(consumer.topic, kp.getPartitionId())) {
                        KafkaConsumer.KafkaMessage kafkaMessage = new KafkaConsumer.KafkaMessage(kp,
                                msg.message(), msg.offset());
                        emitTuple(kafkaMessage);
                        offsetStats.put(kp, msg.offset());
                        count = count + 1;
                        if (count.equals(rc.getValue().right))
                            break;
                    }
                }
            }
        }
        if (windowId == windowDataManager.getLargestCompletedWindow()) {
            // Start the consumer at the largest recovery window
            SimpleKafkaConsumer cons = (SimpleKafkaConsumer) getConsumer();
            // Set the offset positions to the consumer
            Map<KafkaPartition, Long> currentOffsets = new HashMap<KafkaPartition, Long>(
                    cons.getCurrentOffsets());
            // Increment the offsets
            for (Map.Entry<KafkaPartition, Long> e : offsetStats.entrySet()) {
                currentOffsets.put(e.getKey(), e.getValue() + 1);
            }
            cons.resetOffset(currentOffsets);
            cons.start();
        }
    } catch (IOException e) {
        throw new RuntimeException("replay", e);
    }
}

From source file:net.sourceforge.fenixedu.applicationTier.Servico.teacher.onlineTests.InsertTestQuestion.java

protected void run(String executionCourseId, String testId, String[] metadataId, Integer questionOrder,
        Double questionValue, CorrectionFormula formula) throws FenixServiceException {

    for (String element : metadataId) {
        Metadata metadata = FenixFramework.getDomainObject(element);
        if (metadata == null) {
            throw new InvalidArgumentsServiceException();
        }/*from ww w . ja  v a 2  s .com*/
        Question question = null;
        if (metadata.getVisibleQuestions() != null && metadata.getVisibleQuestions().size() != 0) {
            question = metadata.getVisibleQuestions().iterator().next();
        } else {
            throw new InvalidArgumentsServiceException();
        }
        if (question == null) {
            throw new InvalidArgumentsServiceException();
        }
        Test test = FenixFramework.getDomainObject(testId);
        if (test == null) {
            throw new InvalidArgumentsServiceException();
        }
        List<TestQuestion> testQuestionList = new ArrayList<TestQuestion>(test.getTestQuestionsSet());
        Collections.sort(testQuestionList, new BeanComparator("testQuestionOrder"));
        if (testQuestionList != null) {
            if (questionOrder == null || questionOrder.equals(Integer.valueOf(-1))) {
                questionOrder = Integer.valueOf(testQuestionList.size() + 1);
            } else {
                questionOrder = Integer.valueOf(questionOrder.intValue() + 1);
            }
            for (TestQuestion iterTestQuestion : testQuestionList) {
                Integer iterQuestionOrder = iterTestQuestion.getTestQuestionOrder();
                if (questionOrder.compareTo(iterQuestionOrder) <= 0) {
                    iterTestQuestion.setTestQuestionOrder(Integer.valueOf(iterQuestionOrder.intValue() + 1));
                }
            }
        }
        Double thisQuestionValue = questionValue;
        if (questionValue == null) {
            ParseSubQuestion parseQuestion = new ParseSubQuestion();
            if (thisQuestionValue == null) {
                thisQuestionValue = new Double(0);
            }
            try {
                InfoQuestion infoQuestion = InfoQuestion.newInfoFromDomain(question);
                question = parseQuestion.parseSubQuestion(question);
                if (infoQuestion.getQuestionValue() != null) {
                    thisQuestionValue = infoQuestion.getQuestionValue();
                } else {
                    for (SubQuestion subQuestion : question.getSubQuestions()) {
                        if (subQuestion.getQuestionValue() != null) {
                            thisQuestionValue = new Double(thisQuestionValue.doubleValue()
                                    + subQuestion.getQuestionValue().doubleValue());
                        }
                    }
                }

            } catch (Exception e) {
                throw new FenixServiceException(e);
            }

        }
        TestQuestion testQuestion = new TestQuestion();
        test.setLastModifiedDate(Calendar.getInstance().getTime());
        testQuestion.setQuestion(question);
        testQuestion.setTest(test);
        testQuestion.setTestQuestionOrder(questionOrder);
        testQuestion.setTestQuestionValue(thisQuestionValue);
        testQuestion.setCorrectionFormula(formula);
    }
}

From source file:nc.noumea.mairie.organigramme.viewmodel.EditEntiteDtoViewModel.java

private void deplierReplierNiveau(boolean deplier) {
    if (fichePoste != null) {
        Map<FichePosteTreeNodeDto, Integer> mapFdpNiveau = new HashMap<FichePosteTreeNodeDto, Integer>();
        mapFdpNiveau.put(fichePoste, 0);
        mapFdpNiveau = getMapFdpNiveau(fichePoste, mapFdpNiveau, 1);
        Integer maxNiveauOuvert = getMaxNiveauFromMap(mapFdpNiveau);

        List<FichePosteTreeNodeDto> listeFdpDto = new ArrayList<FichePosteTreeNodeDto>();
        listeFdpDto.add(fichePoste);//from  w ww.  j  ava2  s .  com
        Integer niveauRecherche = deplier ? maxNiveauOuvert : maxNiveauOuvert - 1;

        if (!niveauRecherche.equals(0)) {
            if (deplier) {
                for (int niveauParcouru = 0; niveauParcouru <= niveauRecherche; niveauParcouru++) {
                    deplierReplierParNiveau(deplier, listeFdpDto, niveauParcouru);
                }
            } else {
                deplierReplierParNiveau(deplier, listeFdpDto, maxNiveauOuvert - 1);
            }
        }
    }
}

From source file:com.inkubator.hrm.service.impl.LoanNewApplicationServiceImpl.java

private List<LoanPaymentDetail> calculateLoanPaymentDetails(Double interestRate, Integer termin,
        Date loanPaymentDate, Double nominalPrincipal, Integer typeOfInterest) {
    //set parameter for calculating jadwalPembayaran
    LoanPayment loanPayment = new LoanPayment();
    loanPayment.setBungaPertahun(interestRate);
    loanPayment.setLamaPinjaman(termin);
    loanPayment.setPaymentPeriod(1);/*from   w  w w . j a  v  a 2  s  .  co  m*/
    loanPayment.setTanggalBayar(loanPaymentDate);
    loanPayment.setTotalPinjaman(nominalPrincipal);

    //calculate jadwalPembayaran
    if (typeOfInterest.equals(HRMConstant.ANNUITY)) {
        loanPayment = HRMFinanceLib.getLoanPaymentAnuitas(loanPayment);
    } else if (typeOfInterest.equals(HRMConstant.FLAT)) {
        loanPayment = HRMFinanceLib.getLoanPaymentFlateMode(loanPayment);
    } else if (typeOfInterest.equals(HRMConstant.FLOATING)) {
        loanPayment = HRMFinanceLib.getLoanPaymentEffectiveMode(loanPayment);
    }

    //convert jadwalPembayaran to loanPaymentDetails
    List<LoanPaymentDetail> listLoanPaymentDetails = new ArrayList<LoanPaymentDetail>();
    for (JadwalPembayaran jadwalPembayaran : loanPayment.getJadwalPembayarans()) {
        LoanPaymentDetail lpDetail = new LoanPaymentDetail();
        lpDetail.setDueDate(jadwalPembayaran.getTanggalPembayaran());
        lpDetail.setTotalPayment(jadwalPembayaran.getAngsuran());
        lpDetail.setInterest(jadwalPembayaran.getBunga());
        lpDetail.setPrincipal(jadwalPembayaran.getPokok());
        lpDetail.setRemainingPrincipal(jadwalPembayaran.getSisaUtang());
        listLoanPaymentDetails.add(lpDetail);
    }

    return listLoanPaymentDetails;
}

From source file:com.inkubator.hrm.service.impl.LoanNewApplicationServiceImpl.java

private List<LoanNewApplicationInstallment> calculateLoanNewApplicationInstallment(Double interestRate,
        Integer termin, Date loanPaymentDate, Double nominalPrincipal, Integer typeOfInterest) {
    //set parameter for calculating jadwalPembayaran
    LoanPayment loanPayment = new LoanPayment();
    loanPayment.setBungaPertahun(interestRate);
    loanPayment.setLamaPinjaman(termin);
    loanPayment.setPaymentPeriod(1);/*  w w  w.  java  2s .c  o m*/
    loanPayment.setTanggalBayar(loanPaymentDate);
    loanPayment.setTotalPinjaman(nominalPrincipal);

    //calculate jadwalPembayaran
    if (typeOfInterest.equals(HRMConstant.ANNUITY)) {
        loanPayment = HRMFinanceLib.getLoanPaymentAnuitas(loanPayment);
    } else if (typeOfInterest.equals(HRMConstant.FLAT)) {
        loanPayment = HRMFinanceLib.getLoanPaymentFlateMode(loanPayment);
    } else if (typeOfInterest.equals(HRMConstant.FLOATING)) {
        loanPayment = HRMFinanceLib.getLoanPaymentEffectiveMode(loanPayment);
    }

    List<JadwalPembayaran> listjadwalPembayaran = loanPayment.getJadwalPembayarans();
    List<LoanNewApplicationInstallment> listLoanNewApplicationInstallments = new ArrayList<>();

    //convert jadwalPembayaran to loanNewApplicationInstallment
    for (JadwalPembayaran jadwalPembayaran : listjadwalPembayaran) {
        int index = listjadwalPembayaran.indexOf(jadwalPembayaran);
        LoanNewApplicationInstallment loanNewApplicationInstallment = new LoanNewApplicationInstallment();
        loanNewApplicationInstallment.setInstallmentDate(jadwalPembayaran.getTanggalPembayaran());
        loanNewApplicationInstallment.setInterestNominal(jadwalPembayaran.getBunga());
        loanNewApplicationInstallment.setBasicNominal(jadwalPembayaran.getPokok());
        loanNewApplicationInstallment.setTotalPayment(jadwalPembayaran.getAngsuran());
        loanNewApplicationInstallment.setRemainingBasic(jadwalPembayaran.getSisaUtang());
        loanNewApplicationInstallment.setNumOfInstallment(index + 1);
        listLoanNewApplicationInstallments.add(loanNewApplicationInstallment);
    }

    return listLoanNewApplicationInstallments;
}

From source file:gov.nih.nci.cabig.caaers.domain.StudyParticipantAssignment.java

/**
 * Will return the Prior therapy equal to the one provided, if any
 * Accordingly to business rules, 2 prior therapies are equals if they have the same name, othername, startDate.YEAR, startDate.MONTH
 *
 * @param priorTherapy the prior therapy
 * @return the study participant prior therapy
 *///from   w  ww .ja  v  a  2s .  c  om
public StudyParticipantPriorTherapy containsPriorTherapy(SAEReportPriorTherapy priorTherapy) {
    if (priorTherapy == null)
        return null;
    if (priorTherapy.getPriorTherapy() == null && priorTherapy.getOther() == null)
        return null;

    for (StudyParticipantPriorTherapy spaPriorTherapy : getPriorTherapies()) {
        boolean n1 = spaPriorTherapy.getName() == null;
        boolean n2 = priorTherapy.getName() == null;

        if (!(n1 & n2) && (n1 | n2))
            continue;

        if ((n1 && n2) || (spaPriorTherapy.getName().equals(priorTherapy.getName()))) {
            boolean a = spaPriorTherapy.getStartDate() == null;
            boolean b = priorTherapy.getStartDate() == null;

            // both are null
            if (a && b)
                return spaPriorTherapy;

            // exactly one is null
            if (!(a & b) && (a | b))
                continue;

            // both dates are not null
            Integer y1 = spaPriorTherapy.getStartDate().getYear();
            Integer y2 = priorTherapy.getStartDate().getYear();
            Integer m1 = spaPriorTherapy.getStartDate().getMonth();
            Integer m2 = priorTherapy.getStartDate().getMonth();

            if (y1 == null)
                y1 = new Integer(0);
            if (y2 == null)
                y2 = new Integer(0);
            if (m1 == null)
                m1 = new Integer(0);
            if (m2 == null)
                m2 = new Integer(0);

            if (y1.equals(y2) && m1.equals(m2))
                return spaPriorTherapy;
        }
    }
    return null;
}

From source file:com.aiatss.coast.pmm.application.service.agreement.PolicyServiceImpl.java

private PolicyProductPlan findPolicyProductPlanById(Policy policy, PolicyPkgSchemeDetail policyPkgPlanDetail) {

    String PlanCode = policyPkgPlanDetail.getBenefitPlanCode(); // NOSONAR
    Integer PlanProductId = policyPkgPlanDetail.getProductId(); // NOSONAR

    List<PolicyProduct> policyProducts = policy.getPolicyProducts();

    for (PolicyProduct policyProduct : policyProducts) {

        List<PolicyProductPlan> policyProductPlans = policyProduct.getPolicyProductPlans();

        for (PolicyProductPlan policyProductPlan : policyProductPlans) {

            if (PlanCode.equals(policyProductPlan.getBenefitPlanCode())
                    && PlanProductId.equals(policyProductPlan.getProductId())) {

                // returnpolicyProductPlanId =
                // policyProductPlan.getPolicyProductPlanId(); // NOSONAR
                return policyProductPlan;
            }/*from ww  w  . j  a  va  2s.  c o m*/
        }
    }

    throw new BusinessException("policyProductPlanId does not exist !");
}

From source file:com.projectx.mvc.servicehandler.quickregister.QuickRegisterHandler.java

@Override
public ModelAndView initialiseShowDetails(Long entityId, Integer entityType, ModelAndView model) {

    EmailVerificationDetailsDTO emailVerificationDetails = null;

    try {/*from  w  w w  .  j a  va 2  s.com*/
        emailVerificationDetails = getEmailVerificationDetailsByCustomerIdTypeAndEmail(entityId, entityType,
                ENTITY_TYPE_PRIMARY);
    } catch (EmailVerificationDetailNotFoundException e) {
        emailVerificationDetails = new EmailVerificationDetailsDTO();
    }

    MobileVerificationDetailsDTO mobileVerificationDetailsPrimary = null;

    try {
        mobileVerificationDetailsPrimary = getMobileVerificationDetailsByCustomerIdTypeAndMobile(entityId,
                entityType, ENTITY_TYPE_PRIMARY);
    } catch (MobileVerificationDetailsNotFoundException e) {
        mobileVerificationDetailsPrimary = new MobileVerificationDetailsDTO();
    }

    MobileVerificationDetailsDTO mobileVerificationDetailsSeconadry = null;

    if (entityType.equals(ENTITY_TYPE_CUSTOMER)) {
        try {
            mobileVerificationDetailsSeconadry = getMobileVerificationDetailsByCustomerIdTypeAndMobile(entityId,
                    entityType, ENTITY_TYPE_SECONDARY);
        } catch (MobileVerificationDetailsNotFoundException e) {
            mobileVerificationDetailsSeconadry = new MobileVerificationDetailsDTO();
        }
        model.addObject("mobileVerificationDetailsSeconadry", mobileVerificationDetailsSeconadry);
    }

    model.addObject("emailVerificationDetails", emailVerificationDetails);
    model.addObject("mobileVerificationDetailsPrimary", mobileVerificationDetailsPrimary);

    return model;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.CombinedCategoryBar.java

public void configureChart(SourceBean content) {
    super.configureChart(content);
    logger.debug("IN");

    if (confParameters.get("add_labels") != null) {
        String additional = (String) confParameters.get("add_labels");
        if (additional.equalsIgnoreCase("true")) {
            additionalLabels = true;/*from   www  . jav a 2  s.  co m*/
            catSerLabels = new LinkedHashMap();
        } else
            additionalLabels = false;
    } else {
        additionalLabels = false;
    }

    if (confParameters.get("add_labels") != null) {
        String additional = (String) confParameters.get("add_labels");
        if (additional.equalsIgnoreCase("true")) {
            additionalLabels = true;
            catSerLabels = new LinkedHashMap();
        } else
            additionalLabels = false;
    } else {
        additionalLabels = false;
    }

    // In template: <SERIES_DRAW serie1='line' serie2='bar< />

    SourceBean draws = (SourceBean) content.getAttribute("SERIES_DRAW");
    if (draws == null) {
        draws = (SourceBean) content.getAttribute("CONF.SERIES_DRAW");
    }
    seriesDraw = new LinkedHashMap();
    if (draws != null) {

        List atts = draws.getContainedAttributes();
        String serieName = "";
        String serieDraw = "";
        // Run all the series specified in template and check if they are bar or line, by default will be bar; if not specified but present will be bar
        for (Iterator iterator = atts.iterator(); iterator.hasNext();) {
            SourceBeanAttribute object = (SourceBeanAttribute) iterator.next();
            serieName = new String(object.getKey());
            serieDraw = new String((String) object.getValue());

            if (serieDraw.equalsIgnoreCase("line")) {
                seriesDraw.put(serieName, "line");
            } else if (serieDraw.equalsIgnoreCase("line_no_shapes")) {
                seriesDraw.put(serieName, "line_no_shapes");
            } else {
                seriesDraw.put(serieName, "bar");
            }

        }

    }

    if (confParameters.get("second_axis_label") != null) {
        secondAxisLabel = (String) confParameters.get("second_axis_label");
    }

    // check wich series has to be mapped to the first axis and wich to the second
    SourceBean scales = (SourceBean) content.getAttribute("SERIES_SCALES");

    if (scales == null) {
        scales = (SourceBean) content.getAttribute("CONF.SERIES_SCALES");
    }
    seriesScale = new LinkedHashMap(); // Maps serie Name to scale Number (1 or 2)

    if (scales != null) {

        List attsScales = scales.getContainedAttributes();

        String serieName = "";
        Integer serieScale = 1;
        for (Iterator iterator = attsScales.iterator(); iterator.hasNext();) {
            SourceBeanAttribute object = (SourceBeanAttribute) iterator.next();
            serieName = new String(object.getKey());
            try {
                String serieScaleS = (String) object.getValue();
                serieScale = Integer.valueOf(serieScaleS);
            } catch (Exception e) {
                logger.error("Not correct numebr scale; setting default 1");
                serieScale = Integer.valueOf(1);
            }

            if (serieScale.equals(2)) {
                seriesScale.put(serieName, "2");
            } else {
                seriesScale.put(serieName, "1");
            }
        }
    }

    logger.debug("OUT");
}

From source file:com.aurel.track.admin.project.ProjectConfigBL.java

/**
 * Whether an entry is found in a list //from   w w w.java  2  s .c  o m
 * @return
 */
private static Integer getInitStatus(List<TInitStateBean> initStateBeans, Integer projectID,
        Integer itemTypeID) {
    if (initStateBeans != null && projectID != null && itemTypeID != null) {
        for (TInitStateBean initStateBean : initStateBeans) {
            Integer assignedProjectID = initStateBean.getProject();
            Integer assignedItemTypeID = initStateBean.getListType();
            Integer assignedInitStatusID = initStateBean.getStateKey();
            if (projectID.equals(assignedProjectID) && itemTypeID.equals(assignedItemTypeID)) {
                return assignedInitStatusID;
            }
        }
    }
    return null;
}