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:iwein.samples.store.SimpleMessageGroup.java

private boolean containsSequenceNumber(Collection<Message<?>> messages, Integer messageSequenceNumber) {
    for (Message<?> member : messages) {
        Integer memberSequenceNumber = member.getHeaders().getSequenceNumber();
        if (messageSequenceNumber.equals(memberSequenceNumber)) {
            return true;
        }//from w  w w. ja v  a2s .co  m
    }
    return false;
}

From source file:com.aurel.track.item.link.ItemLinkBL.java

/**
 * Gets the links for a workItem//from w ww  .ja  v a2 s  . com
 * @param itemID
 * @return
 */
public static List<Integer> getLinkedItemIDs(Integer itemID, Integer linkType, Integer linkDirection) {
    boolean bidirectional = LinkTypeBL.isBidirectional(linkType);
    List<TWorkItemLinkBean> linkList = null;
    List<TWorkItemLinkBean> reverseLinkList = null;
    List<TWorkItemLinkBean> linkAndReverseLinkList = new LinkedList<TWorkItemLinkBean>();
    if (bidirectional) {
        List<Integer> linkedItemIDs = new LinkedList<Integer>();
        if (linkDirection.intValue() == ILinkType.LINK_DIRECTION.UNIDIRECTIONAL_OUTWARD) {
            linkList = loadByPredAndLinkType(itemID, linkType, linkDirection);
            linkAndReverseLinkList.addAll(linkList);
            //linkedItemIDs.addAll(getLinkedItemIDs(linkList, true));
            int reverseDirection = LinkTypeBL.getReverseDirection(linkDirection);
            reverseLinkList = loadBySuccAndLinkType(itemID, linkType, reverseDirection);
            linkAndReverseLinkList.addAll(reverseLinkList);
            //linkedItemIDs.addAll(getLinkedItemIDs(reverseLinkList, false));
        } else {
            if (linkDirection.intValue() == ILinkType.LINK_DIRECTION.UNIDIRECTIONAL_INWARD) {
                reverseLinkList = loadByPredAndLinkType(itemID, linkType, linkDirection);
                linkAndReverseLinkList.addAll(reverseLinkList);
                //linkedItemIDs.addAll(getLinkedItemIDs(reverseLinkList, true));
                int reverseDirection = LinkTypeBL.getReverseDirection(linkDirection);
                linkList = loadBySuccAndLinkType(itemID, linkType, reverseDirection);
                linkAndReverseLinkList.addAll(linkList);
                //linkedItemIDs.addAll(getLinkedItemIDs(linkList, false));
            }
        }
        //merge the the links from two directions together by sort order
        Collections.sort(linkAndReverseLinkList);
        for (TWorkItemLinkBean workItemLinkBean : linkAndReverseLinkList) {
            Integer succ = workItemLinkBean.getLinkSucc();
            Integer pred = workItemLinkBean.getLinkPred();
            if (succ != null && pred != null) {
                if (!succ.equals(itemID)) {
                    linkedItemIDs.add(succ);
                } else {
                    if (!pred.equals(itemID)) {
                        linkedItemIDs.add(pred);
                    }
                }
            }
        }
        return linkedItemIDs;
    } else {
        if (linkDirection.intValue() == ILinkType.LINK_DIRECTION.UNIDIRECTIONAL_OUTWARD) {
            linkList = loadByPredAndLinkType(itemID, linkType, linkDirection);
            return getLinkedItemIDs(linkList, true);
        } else {
            if (linkDirection.intValue() == ILinkType.LINK_DIRECTION.UNIDIRECTIONAL_INWARD) {
                linkList = loadBySuccAndLinkType(itemID, linkType, linkDirection);
                return getLinkedItemIDs(linkList, false);
            }
        }
    }
    return null;
}

From source file:com.solidmaps.webapp.service.LicensePFServiceImpl.java

/**
 * Valida se h Produtos a mais ou a menos em relao a ultima Licensa
 * /*  w  w w.ja va 2 s. c o  m*/
 * @param entity
 * @param listaProducts
 */
private LicenseValidationVO validateProducts(LicensePFEntity entity, List<Integer> listaProducts) {
    LicensePFEntity license = licenseDAO.findLastLicense(entity.getCompany().getIdCompany());
    LicenseValidationVO licenseValidation = new LicenseValidationVO();

    if (license == null) {
        return licenseValidation;
    }

    // Cria a lista de Produtos que esto faltando em relao a Licensa anterior
    for (ProductOfficialEntity product : license.getListProducts()) {
        if (!listaProducts.contains(product.getIdProduct())) {
            licenseValidation.getListMissedProducts().add(product);
        }
    }

    // Cria a lista de Produtos foram inseridos a mais na licensa

    // TODO ser que eh o melhor jeito de fazer essa merda??
    for (Integer idProduct : listaProducts) {

        boolean exists = false;
        for (ProductOfficialEntity product : license.getListProducts()) {

            if (idProduct.equals(product.getIdProduct())) {
                exists = true;
                break;
            }

        }

        if (!exists) {
            licenseValidation.getListNewProducts().add(productOfficialDAO.findById(idProduct));
        }

    }

    return licenseValidation;
}

From source file:es.upm.fiware.rss.service.CdrsManager.java

/**
 * Saves a list of CDRs in the database as transactionss
 * @param cdrs, CDRs containing transaction information
 * @throws RSSException, If the CDR information is not valid
 *//*  w w  w  .ja v a 2s .  c  o  m*/
public void createCDRs(List<CDR> cdrs) throws RSSException {

    // Process CDRs one by one
    for (CDR cdr : cdrs) {
        // Check if the user has permission to create a new transaction
        if (!userManager.isAdmin()
                && !userManager.getCurrentUser().getEmail().equalsIgnoreCase(cdr.getCdrSource())) {
            String[] args = { "You are not allowed to register a transaction for the Store owned by "
                    + cdr.getCdrSource() };
            throw new RSSException(UNICAExceptionType.NON_ALLOWED_OPERATION, args);
        }

        // Check that the aggregator (CDR Source) exists
        DbeAggregator aggregator = this.aggregatorDao.getById(cdr.getCdrSource());

        if (aggregator == null) {
            String[] args = { "The Store identified by  " + cdr.getCdrSource() + " does not exists" };
            throw new RSSException(UNICAExceptionType.NON_EXISTENT_RESOURCE_ID, args);
        }

        // Validate the provider
        this.modelsManager.checkValidAppProvider(cdr.getCdrSource(), cdr.getAppProvider());
        DbeAppProvider provider = this.appProviderDao.getProvider(cdr.getCdrSource(), cdr.getAppProvider());

        // Validate the currency
        BmCurrency currency = this.currencyDao.getByIso4217StringCode(cdr.getCurrency());

        if (currency == null) {
            String[] args = { "The currency  " + cdr.getCurrency() + " is not supported" };
            throw new RSSException(UNICAExceptionType.NON_EXISTENT_RESOURCE_ID, args);
        }

        // Validate correlation number and timestamp
        Integer nextCorr = provider.getTxCorrelationNumber();
        if (!nextCorr.equals(cdr.getCorrelationNumber())) {
            String[] args = { "Invalid correlation number, expected: " + nextCorr };
            throw new RSSException(UNICAExceptionType.INVALID_PARAMETER, args);
        }

        provider.setTxCorrelationNumber(nextCorr + 1);

        Date prevTime = provider.getTxTimeStamp();
        if (cdr.getTimestamp() == null || prevTime.after(cdr.getTimestamp())) {
            String[] args = { "Invalid timestamp: The given time is earlier that the prevoius one" };
            throw new RSSException(UNICAExceptionType.INVALID_PARAMETER, args);
        }

        provider.setTxTimeStamp(cdr.getTimestamp());

        // Validate transaction type
        if (!cdr.getTransactionType().equalsIgnoreCase("C")
                && !cdr.getTransactionType().equalsIgnoreCase("R")) {

            String[] args = { "The transaction type " + cdr.getTransactionType()
                    + " is not supported, must be C (charge) or R (refund)" };
            throw new RSSException(UNICAExceptionType.INVALID_PARAMETER, args);
        }

        // Save CDR to the database
        DbeTransaction tx = new DbeTransaction();

        if (cdr.getProductClass() == null || cdr.getProductClass().isEmpty()) {
            String[] args = { "Missing productClass" };
            throw new RSSException(UNICAExceptionType.MISSING_MANDATORY_PARAMETER, args);
        }

        if (cdr.getReferenceCode() == null || cdr.getReferenceCode().isEmpty()) {
            String[] args = { "Missing referenceCode" };
            throw new RSSException(UNICAExceptionType.MISSING_MANDATORY_PARAMETER, args);
        }

        tx.setTxProductClass(cdr.getProductClass());
        tx.setState("pending");
        tx.setCdrSource(aggregator);
        tx.setTxPbCorrelationId(cdr.getCorrelationNumber());
        tx.setTsClientDate(cdr.getTimestamp());
        tx.setTxApplicationId(cdr.getApplication());
        tx.setTcTransactionType(cdr.getTransactionType());
        tx.setTxEvent(cdr.getEvent());
        tx.setTxReferenceCode(cdr.getReferenceCode());
        tx.setTxOperationNature(cdr.getDescription());
        tx.setFtChargedAmount(cdr.getChargedAmount());
        tx.setFtChargedTaxAmount(cdr.getChargedTaxAmount());
        tx.setBmCurrency(currency);
        tx.setTxEndUserId(cdr.getCustomerId());
        tx.setAppProvider(provider);

        try {
            this.transactionDao.create(tx);
        } catch (org.hibernate.NonUniqueObjectException e) {
            String msg = "This transaction has been already registered:"
                    + "For a given transaction the provider, the reference, "
                    + " and the correlation number must be unique";

            String[] args = { msg };
            throw new RSSException(UNICAExceptionType.RESOURCE_ALREADY_EXISTS, args);
        }
    }
}

From source file:com.nagarro.core.v2.controller.CartsController.java

private static OrderEntryData getCartEntryForNumber(final CartData cart, final long number)
        throws CartEntryException {
    final List<OrderEntryData> entries = cart.getEntries();
    if (entries != null && !entries.isEmpty()) {
        final Integer requestedEntryNumber = Integer.valueOf((int) number);
        for (final OrderEntryData entry : entries) {
            if (entry != null && requestedEntryNumber.equals(entry.getEntryNumber())) {
                return entry;
            }/*  ww  w .jav  a2 s. co m*/
        }
    }
    throw new CartEntryException("Entry not found", CartEntryException.NOT_FOUND, String.valueOf(number));
}

From source file:de.bayern.gdi.WfsTest.java

private void checkFeaturesPerPage(WFSMeta wfsMeta) {

    StringBuilder sb = new StringBuilder();
    sb.append(wfsMeta.title);//from w w w . ja v a  2s  .c  o  m
    sb.append(" - ");
    sb.append("FeaturesPerPage parsing failed.");

    Integer fpp = wfsMeta.findOperation("GetFeature").featuresPerPage();
    if (fpp == null) { // Fall back to global default.
        fpp = wfsMeta.featuresPerPage();
    }

    if (fpp == null || !fpp.equals(FEATURES_PER_PAGE)) {
        assertFalse(sb.toString(), true);
    }
}

From source file:com.gst.portfolio.loanaccount.serialization.CalculateLoanScheduleQueryFromApiJsonHelper.java

public void validateSelectedPeriodFrequencyTypeIsTheSame(final List<ApiParameterError> dataValidationErrors,
        final Integer loanTermFrequency, final Integer loanTermFrequencyType, final Integer numberOfRepayments,
        final Integer repaymentEvery, final Integer repaymentEveryType) {
    if (loanTermFrequencyType != null && !loanTermFrequencyType.equals(repaymentEveryType)) {
        final ApiParameterError error = ApiParameterError.parameterError(
                "validation.msg.loan.loanTermFrequencyType.not.the.same.as.repaymentFrequencyType",
                "The parameters loanTermFrequencyType and repaymentFrequencyType must be the same.",
                "loanTermFrequencyType", loanTermFrequencyType, repaymentEveryType);
        dataValidationErrors.add(error);
    } else {//w  w  w  .jav a 2 s . com
        if (loanTermFrequency != null && repaymentEvery != null && numberOfRepayments != null) {
            final int suggestsedLoanTerm = repaymentEvery * numberOfRepayments;
            if (loanTermFrequency.intValue() < suggestsedLoanTerm) {
                final ApiParameterError error = ApiParameterError.parameterError(
                        "validation.msg.loan.loanTermFrequency.less.than.repayment.structure.suggests",
                        "The parameter loanTermFrequency is less than the suggest loan term as indicated by numberOfRepayments and repaymentEvery.",
                        "loanTermFrequency", loanTermFrequency, numberOfRepayments, repaymentEvery);
                dataValidationErrors.add(error);
            }
        }
    }
}

From source file:org.dspace.app.webui.cris.controller.statistics.CrisStatisticsController.java

public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String id = getId(request);/*w w  w .j  a va2 s . c  o m*/
    String type = request.getParameter("type");
    String mode = request.getParameter("mode");
    if (mode == null || mode.isEmpty()) {
        mode = StatsComponent.VIEW;
    }
    if (type == null || type.isEmpty()) {
        type = StatComponentsService._SELECTED_OBJECT;
    }
    ModelAndView modelAndView = new ModelAndView(success);
    try {
        Map<String, Object> data = new HashMap<String, Object>();
        data.put(_ID_LABEL, id);
        data.put(_JSP_KEY, jspKey);
        HttpSolrServer solrServer = new HttpSolrServer(getSolrConfig().getStatisticsCore());

        Map<String, IStatsDualComponent> components = statsComponentsService.getComponents();
        TwoKeyMap label = new TwoKeyMap();
        TreeKeyMap dataBeans = new TreeKeyMap();
        IStatsComponent statcomponent = null;

        // create right menu
        List<RightMenuBean> rightMenu = new ArrayList<RightMenuBean>();
        if (statsComponentsService.isShowSelectedObject()) {
            RightMenuBean menuV = new RightMenuBean();
            menuV.setMode(StatsComponent.VIEW);
            menuV.setType(AStatComponentService._SELECTED_OBJECT);
            if (type.equals(menuV.getType()) && mode.equals(menuV.getMode())) {
                menuV.setCurrent(true);
            }
            rightMenu.add(menuV);

            RightMenuBean menuD = new RightMenuBean();
            menuD.setMode(StatsComponent.DOWNLOAD);
            menuD.setType(AStatComponentService._SELECTED_OBJECT);
            if (type.equals(menuD.getType()) && mode.equals(menuD.getMode())) {
                menuD.setCurrent(true);
            }
            rightMenu.add(menuD);
        }

        for (String key : components.keySet()) {
            boolean createMenu = true;
            if (ResearchObject.class.isAssignableFrom(getTarget())) {
                String relationName = ((ICRISComponent) components.get(key)).getRelationConfiguration()
                        .getRelationName();
                if (!relationName.startsWith(getApplicationService()
                        .get(ResearchObject.class, Integer.parseInt(id)).getTypeText())) {
                    createMenu = false;
                }
            }

            if (createMenu) {
                RightMenuBean menuV = new RightMenuBean();
                menuV.setMode(StatsComponent.VIEW);
                menuV.setType(key);
                if (type.equals(menuV.getType()) && mode.equals(menuV.getMode())) {
                    menuV.setCurrent(true);
                }
                rightMenu.add(menuV);

                RightMenuBean menuD = new RightMenuBean();
                menuD.setMode(StatsComponent.DOWNLOAD);
                menuD.setType(key);
                if (type.equals(menuD.getType()) && mode.equals(menuD.getMode())) {
                    menuD.setCurrent(true);
                }
                rightMenu.add(menuD);
            }
        }

        if (components.containsKey(type)) {
            if (mode.equals(StatsComponent.VIEW)) {
                statcomponent = components.get(type).getStatsViewComponent();
            }
            if (mode.equals(StatsComponent.DOWNLOAD)) {
                statcomponent = components.get(type).getStatsDownloadComponent();
            }
        } else {
            if (mode.equals(StatsComponent.VIEW)) {
                statcomponent = statsComponentsService.getSelectedObjectComponent().getStatsViewComponent();
            }
            if (mode.equals(StatsComponent.DOWNLOAD)) {
                statcomponent = statsComponentsService.getSelectedObjectComponent().getStatsDownloadComponent();
            }

        }

        Integer relationObjectType = statcomponent.getRelationObjectType();
        if (relationObjectType.equals(CrisConstants.CRIS_DYNAMIC_TYPE_ID_START)) {
            relationObjectType = getApplicationService().get(ResearchObject.class, Integer.parseInt(id))
                    .getType();
            statcomponent.setRelationObjectType(relationObjectType);
        }

        dataBeans.putAll(statcomponent.query(id, solrServer));
        label.putAll(statcomponent.getLabels(UIUtil.obtainContext(request),
                CrisConstants.getEntityTypeText(relationObjectType)));

        ResultBean result = new ResultBean(dataBeans, statsComponentsService.getCommonsParams());
        data.put(_RESULT_BEAN, result);
        data.put("label", label);
        data.put("title", getTitle(request));
        data.put("object", getObject(request));
        data.put("target", getTarget());
        data.put("rightMenu", rightMenu);
        data.put("relationType", CrisConstants.getEntityTypeText(relationObjectType));
        data.put("showExtraTab", statsComponentsService.isShowExtraTab());
        modelAndView.addObject("data", data);
        addSubscriptionStatus(modelAndView, request);

    } catch (Exception e) {
        log.error(e.getMessage(), e);
        modelAndView = new ModelAndView(error);
    }
    return modelAndView;
}

From source file:de.hybris.platform.order.impl.DefaultCartService.java

private CartEntryModel getEntry(final List<CartEntryModel> entries, final Integer entryNumber) {
    for (final CartEntryModel e : entries) {
        if (entryNumber.equals(e.getEntryNumber())) {
            return e;
        }/*  w  w  w . j a v a  2  s.  c  o m*/
    }
    throw new IllegalArgumentException(
            "no cart entry found with entry number " + entryNumber + " (got " + entries + ")");
}

From source file:org.springbyexample.web.orm.repository.PersonRepositoryTest.java

@Test
@DirtiesContext // reset context so in memory DB re-inits
public void testHibernateTemplate() throws SQLException {
    assertNotNull("Person DAO is null.", personDao);

    Collection<Person> lPersons = personDao.findAll();

    int expected = 3;

    assertNotNull("Person list is null.", lPersons);
    assertEquals("Number of persons should be " + expected + ".", expected, lPersons.size());

    Integer firstId = new Integer(1);
    Integer secondId = new Integer(2);

    for (Person person : lPersons) {
        assertNotNull("Person is null.", person);

        if (firstId.equals(person.getId())) {
            String firstName = "Joe";
            String lastName = "Smith";

            int expectedAddresses = 1;

            assertEquals("Person first name should be " + firstName + ".", firstName, person.getFirstName());
            assertEquals("Person last name should be " + lastName + ".", lastName, person.getLastName());

            assertNotNull("Person's address list is null.", person.getAddresses());
            assertEquals("Number of person's address list should be " + expectedAddresses + ".",
                    expectedAddresses, person.getAddresses().size());

            Integer addressId = new Integer(1);
            String addr = "1060 West Addison St.";
            String city = "Chicago";
            String state = "IL";
            String zipPostal = "60613";

            for (Address address : person.getAddresses()) {
                assertNotNull("Address is null.", address);

                assertEquals("Address id should be '" + addressId + "'.", addressId, address.getId());
                assertEquals("Address address should be '" + address + "'.", addr, address.getAddress());

                assertEquals("Address city should be '" + city + "'.", city, address.getCity());
                assertEquals("Address state should be '" + state + "'.", state, address.getState());
                assertEquals("Address zip/postal should be '" + zipPostal + "'.", zipPostal,
                        address.getZipPostal());
            }/*from  w  ww.j  a va2 s  . c  om*/
        }

        if (secondId.equals(person.getId())) {
            String firstName = "John";
            String lastName = "Wilson";

            int expectedAddresses = 2;

            assertEquals("Person first name should be " + firstName + ".", firstName, person.getFirstName());
            assertEquals("Person last name should be " + lastName + ".", lastName, person.getLastName());

            assertNotNull("Person's address list is null.", person.getAddresses());
            assertEquals("Number of person's address list should be " + expectedAddresses + ".",
                    expectedAddresses, person.getAddresses().size());

            Integer addressId = new Integer(3);
            String addr = "47 Howard St.";
            String city = "San Francisco";
            String state = "CA";
            String zipPostal = "94103";

            for (Address address : person.getAddresses()) {
                assertNotNull("Address is null.", address);

                if (addressId.equals(address.getId())) {
                    assertEquals("Address id should be '" + addressId + "'.", addressId, address.getId());
                    assertEquals("Address address should be '" + address + "'.", addr, address.getAddress());

                    assertEquals("Address city should be '" + city + "'.", city, address.getCity());
                    assertEquals("Address state should be '" + state + "'.", state, address.getState());
                    assertEquals("Address zip/postal should be '" + zipPostal + "'.", zipPostal,
                            address.getZipPostal());
                }
            }
        }

        logger.debug(person.toString());
    }
}