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.aurel.track.admin.customize.category.CategoryBL.java

/**
 * Deletes a category or leaf//  ww w . j a va2s .com
 * @param node
 * @param deleteConfirmed
 * @param personBean
 * @param locale
 * @param servletResponse
 */
public static void delete(String node, boolean deleteConfirmed, TPersonBean personBean, Locale locale,
        HttpServletResponse servletResponse) {
    CategoryTokens categoryTokens = CategoryTokens.decodeNode(node);
    Integer type = categoryTokens.getType();
    String categoryType = categoryTokens.getCategoryType();
    Integer objectID = categoryTokens.getObjectID();
    CategoryFacade categoryFacade = CategoryFacadeFactory.getInstance().getCategoryFacade(categoryType);
    LeafFacade leafFacade = CategoryFacadeFactory.getInstance().getLeafFacade(categoryType);
    CategoryBaseFacade categoryBaseFacade = null;
    boolean leafReplaceNeeded = false;
    if (type.equals(Integer.valueOf(TYPE.LEAF))) {
        categoryBaseFacade = CategoryFacadeFactory.getInstance().getLeafFacade(categoryType);
        leafReplaceNeeded = leafFacade.replaceNeeded(objectID);

        if (FilterBL.filterIsPredefined(objectID)) {
            String localizedLabel = LocalizeUtil.getLocalizedEntity(LocalizationKeyPrefixes.FILTER_LABEL_PREFIX,
                    objectID, locale);
            String errorMessage = LocalizeUtil.getParametrizedString(
                    "admin.customize.queryFilter.deletePredefinedFilter", new Object[] { localizedLabel },
                    locale);
            JSONUtility.encodeJSON(servletResponse, JSONUtility.encodeJSONFailure(errorMessage,
                    JSONUtility.DELETE_ERROR_CODES.NO_RIGHT_TO_DELETE));
            return;
        }
    }
    boolean categoryReplaceNeeded = false;
    boolean categoryHasDependentData = false;
    if (type.equals(Integer.valueOf(TYPE.CATEGORY))) {
        categoryReplaceNeeded = categoryFacade.replaceNeeded(objectID);
        categoryHasDependentData = categoryFacade.hasDependentData(objectID);
        categoryBaseFacade = CategoryFacadeFactory.getInstance().getCategoryFacade(categoryType);
        Integer predefinedFilter = CategoryBL.hasPredefinedFilter(categoryType, objectID);
        if (predefinedFilter != null) {
            String localizedLabel = LocalizeUtil.getLocalizedEntity(LocalizationKeyPrefixes.FILTER_LABEL_PREFIX,
                    predefinedFilter, locale);
            String errorMessage = LocalizeUtil.getParametrizedString(
                    "admin.customize.queryFilter.deleteCategoryWithPredefinedFilter",
                    new Object[] { localizedLabel }, locale);
            JSONUtility.encodeJSON(servletResponse, JSONUtility.encodeJSONFailure(errorMessage,
                    JSONUtility.DELETE_ERROR_CODES.NO_RIGHT_TO_DELETE));
            return;
        }
    }
    //whether the user has delete right on this node
    if (!CategoryBL.isModifiable(categoryBaseFacade, categoryType, categoryTokens.getRepository(), type,
            objectID, false, personBean)) {
        String errorMessage = LocalizeUtil.getParametrizedString("common.lbl.noDeleteRight",
                new Object[] { getLocaleKeyByCategoryKey(categoryType) }, locale);
        JSONUtility.encodeJSON(servletResponse,
                JSONUtility.encodeJSONFailure(errorMessage, JSONUtility.DELETE_ERROR_CODES.NO_RIGHT_TO_DELETE));
        return;
    }

    if (deleteConfirmed || (type.equals(Integer.valueOf(TYPE.LEAF)) && !leafReplaceNeeded)
            || (type.equals(Integer.valueOf(TYPE.CATEGORY))
                    && !(categoryReplaceNeeded || categoryHasDependentData))) {
        //delete if it has no dependency
        if (categoryBaseFacade != null) {
            categoryBaseFacade.delete(objectID, categoryType);
        }
        JSONUtility.encodeJSON(servletResponse, JSONUtility.encodeJSONSuccess());
    } else {
        if (type.equals(Integer.valueOf(TYPE.LEAF))) {
            //dependent leaf: prepare replacement tree
            JSONUtility.encodeJSON(servletResponse,
                    JSONUtility.encodeJSONFailure(DELETE_ERROR_CODES.NEED_REPLACE));
        } else {
            if (categoryReplaceNeeded) {
                //category has dependent leafs: prepare replacement tree
                JSONUtility.encodeJSON(servletResponse,
                        JSONUtility.encodeJSONFailure(DELETE_ERROR_CODES.NEED_REPLACE));
            } else {
                //a not empty category but does not has dependent leafs: just ask for confirmation
                String errorMessage = LocalizeUtil.getParametrizedString(
                        "admin.customize.queryFilter.deleteWarning",
                        new Object[] { LocalizeUtil.getLocalizedTextFromApplicationResources(
                                "admin.customize.queryFilter.lbl.category", locale) },
                        locale);
                JSONUtility.encodeJSON(servletResponse,
                        JSONUtility.encodeJSONFailure(errorMessage, DELETE_ERROR_CODES.NOT_EMPTY_WARNING));
            }
        }
    }
}

From source file:com.redsqirl.dynamictable.UnselectableTable.java

public void sort(final Integer index) {
    logger.info("Sort " + index);

    if (index == null || index < 0 || index >= columnIds.size()) {
        return;//from w  ww. j  a v  a2  s .c om
    }

    if (index.equals(indexOrdered)) {
        order *= -1;
    } else {
        indexOrdered = index;
        order = 1;
    }
    final Integer ord = order;
    Collections.sort(rows, new Comparator<Comparable[]>() {
        @SuppressWarnings("unchecked")
        @Override
        public int compare(Comparable[] o1, Comparable[] o2) {
            if (o1[index] == null) {
                return o2[index] == null ? 0 : -ord;
            } else if (o2[index] == null) {
                return ord;
            }

            return ord * o1[index].compareTo(o2[index]);
        }
    });
}

From source file:com.esofthead.mycollab.vaadin.ui.MultiSelectComp.java

private boolean compareVal(T value1, T value2) {
    if (value1 == null && value2 == null) {
        return true;
    } else if (value1 == null || value2 == null) {
        return false;
    } else {//from  w w  w .  j av  a 2 s.  c o  m
        try {
            Integer field1 = (Integer) PropertyUtils.getProperty(value1, "id");
            Integer field2 = (Integer) PropertyUtils.getProperty(value2, "id");
            return field1.equals(field2);
        } catch (final Exception e) {
            log.error("Error when compare value", e);
            return false;
        }
    }
}

From source file:nc.noumea.mairie.appock.services.impl.StockServiceImpl.java

@Override
public void creeEntreeSortieEtMouvement(ArticleStock articleStock, Integer quantiteRenseigne,
        TypeMouvementStock typeMouvementStock, String observation) {
    Integer oldQuantite = articleStock.getQuantiteStock();
    String reference = articleStock.getReferenceArticleStock();
    Stock stock = articleStock.getStock();

    Integer quantiteActuelle = articleStock.getQuantiteStock();
    Integer nouvelleQuantite = typeMouvementStock == TypeMouvementStock.SORTIE
            ? (quantiteActuelle - quantiteRenseigne)
            : (quantiteActuelle + quantiteRenseigne);

    if (nouvelleQuantite.equals(0)) {
        stock.removeArticleStock(articleStock);
    } else {/*from  w w w . j  a  v  a 2  s .  c o  m*/
        articleStock.setQuantiteStock(nouvelleQuantite);
        articleStockRepository.save(articleStock);
    }

    AppUser currentUser = authHelper.getCurrentUser();

    MouvementStock mouvementStock = new MouvementStock();
    mouvementStock.setDateMouvement(LocalDateTime.now());
    mouvementStock.setMouvementUser(currentUser.getNomComplet());
    mouvementStock.setQuantiteRenseigne(quantiteRenseigne);
    mouvementStock.setOldQuantiteStock(oldQuantite);
    mouvementStock.setNewQuantiteStock(nouvelleQuantite);
    mouvementStock.setObservation(observation);
    mouvementStock.setReference(reference);
    mouvementStock.setTypeMouvementStock(typeMouvementStock);
    mouvementStock.setStock(stock);
    stock.getListeMouvementStock().add(mouvementStock);
    stockRepository.save(stock);
}

From source file:org.devgateway.ocds.web.rest.controller.CorruptionRiskDashboardIndicatorsStatsController.java

/**
 * Finds a specific {@link DBObject} by year and by type (if available) and (if available) month.
 * Very inefficient but we have only 10-12 entries so simplicity prevails :-)
 *
 * @param year/*from  ww  w . j  av a2s  .c o m*/
 * @param month
 * @return
 */
private List<DBObject> findByYearAndTypeAndMonth(List<DBObject> source, Integer year, String type,
        Integer month) {
    return source.stream()
            .filter(o -> year.equals(o.get(Keys.YEAR)) && (type == null || type.equals(o.get(Keys.TYPE)))
                    && (month == null || month.equals(o.get(Keys.MONTH))))
            .collect(Collectors.toList());
}

From source file:desktopsearch.ExploreFiles.java

private void UpdateIndexingProgress(Integer UpdateAttribute) {

    try {//  ww  w.j  a va  2  s.  c  om

        String Query = "UPDATE IndexingInfo SET ";
        if (UpdateAttribute.equals(FileWritingFinishedIndicator)) {
            Query = Query
                    + "IsFileWritingComplete=1 WHERE IndexID IN (SELECT max(IndexID) AS MaxID FROM IndexingInfo);";
        } else if (UpdateAttribute.equals(IndexingFinishedIndicator)) {
            Query = Query
                    + "IsIndexingComplete=1 WHERE IndexID IN (SELECT max(IndexID) AS MaxID FROM IndexingInfo) ;";
        }
        statement.executeUpdate(Query);
        connection.commit();

    } catch (SQLException e) {
        e.printStackTrace();
    }
}

From source file:com.clust4j.algo.HierarchicalTests.java

@Test
public void testHeapifier() {
    // Test heapify initial
    final SimpleHeap<Integer> x = new SimpleHeap<>(
            new ArrayList<>(Arrays.asList(new Integer[] { 19, 56, 1, 52, 7, 2, 23 })));
    assertTrue(x.equals(new ArrayList<Integer>(Arrays.asList(new Integer[] { 1, 7, 2, 52, 56, 19, 23 }))));

    // Test push pop
    Integer i = x.pushPop(2);
    assertTrue(i.equals(1));
    assertTrue(x.equals(new ArrayList<Integer>(Arrays.asList(new Integer[] { 2, 7, 2, 52, 56, 19, 23 }))));

    // Test pop/*from   ww  w.jav  a  2  s. com*/
    i = x.pop();
    assertTrue(i.equals(2));
    assertTrue(x.equals(new ArrayList<Integer>(Arrays.asList(new Integer[] { 2, 7, 19, 52, 56, 23 }))));

    // Test push
    x.push(9);
    assertTrue(x.equals(new ArrayList<Integer>(Arrays.asList(new Integer[] { 2, 7, 9, 52, 56, 23, 19 }))));

    while (!x.isEmpty())
        x.popInPlace();

    assertTrue(x.size() == 0);
}

From source file:net.sourceforge.fenixedu.presentationTier.TagLib.sop.examsMapNew.renderers.ExamsMapContentRenderer.java

@Override
public StringBuilder renderDayContents(ExamsMapSlot examsMapSlot, Integer year1, Integer year2, String typeUser,
        PageContext pageContext) {/*  w w  w  .j  a  v a 2s .co  m*/
    StringBuilder strBuffer = new StringBuilder();

    for (int i = 0; i < examsMapSlot.getExams().size(); i++) {
        InfoExam infoExam = (InfoExam) examsMapSlot.getExams().get(i);
        Integer curicularYear = infoExam.getInfoExecutionCourse().getCurricularYear();

        if (curicularYear.equals(year1) || curicularYear.equals(year2)) {
            boolean isOnValidWeekDay = onValidWeekDay(infoExam);

            InfoExecutionCourse infoExecutionCourse = infoExam.getInfoExecutionCourse();
            String courseInitials = infoExam.getInfoExecutionCourse().getSigla();

            if (typeUser.equals("sop")) {
                strBuffer.append("<a href='showExamsManagement.do?method=edit&amp;"
                        + PresentationConstants.EXECUTION_COURSE_OID + "=" + infoExecutionCourse.getExternalId()
                        + "&amp;" + PresentationConstants.EXECUTION_PERIOD_OID + "="
                        + infoExecutionCourse.getInfoExecutionPeriod().getExternalId() + "&amp;"
                        + PresentationConstants.EXECUTION_DEGREE_OID + "="
                        + examsMap.getInfoExecutionDegree().getExternalId() + "&amp;"
                        + PresentationConstants.CURRICULAR_YEAR_OID + "=" + curicularYear.toString() + "&amp;"
                        + PresentationConstants.EXAM_OID + "=" + infoExam.getExternalId() + "'>");
                if (isOnValidWeekDay) {
                    strBuffer.append(courseInitials);
                } else {
                    strBuffer.append("<span class='redtxt'>" + courseInitials + "</span>");
                }

            } else if (typeUser.equals("public")) {

                final Site site = infoExecutionCourse.getExecutionCourse().getSite();
                strBuffer.append(GenericChecksumRewriter.NO_CHECKSUM_PREFIX);
                strBuffer.append("<a href=\"")
                        .append(((HttpServletRequest) pageContext.getRequest()).getContextPath());
                strBuffer.append(site.getReversePath());
                strBuffer.append("\">");
                strBuffer.append(courseInitials);
            }

            strBuffer.append("</a>");
            if (infoExam.getBeginning() != null) {
                boolean isAtValidHour = atValidHour(infoExam);
                String hoursText = infoExam.getBeginning().get(Calendar.HOUR_OF_DAY) + "h"
                        + DateFormatUtils.format(infoExam.getBeginning().getTime(), "mm");
                strBuffer.append(" ");
                strBuffer.append(getMessageResource(pageContext, "public.degree.information.label.as"));
                strBuffer.append(" ");

                if (isAtValidHour || !typeUser.equals("sop")) {
                    strBuffer.append(hoursText);
                } else {
                    strBuffer.append("<span class='redtxt'>" + hoursText + "</span>");
                }
            }

            strBuffer.append("<br />");
        }
    }

    strBuffer.append("<br />");

    return strBuffer;
}

From source file:alfio.manager.WaitingQueueManager.java

private Optional<TicketCategory> findBestCategory(List<TicketCategory> unboundedCategories,
        WaitingQueueSubscription subscription) {
    Integer selectedCategoryId = subscription.getSelectedCategoryId();
    return unboundedCategories.stream()
            .filter(tc -> selectedCategoryId == null || selectedCategoryId.equals(tc.getId())).findFirst();
}

From source file:fr.scc.elo.controller.manager.impl.EloManagerImpl.java

private Player showAndUpdatePlayer(String name, String elo, String eloType, Boolean save) throws EloException {
    boolean modified = false;
    Player player = eloService.getPlayer(name);
    if (player == null) {
        if (!save) {
            throw new PlayerNotFoundException();
        }//from w  w w .j av a  2s  .c om
        player = new Player(name);
        modified = true;
    }
    if (elo != null && NumberUtils.isNumber(elo)) {
        Integer scoreElo = player.getElo(EloType.fromName(eloType));
        Integer newElo = Integer.valueOf(elo);
        if (!scoreElo.equals(newElo)) {
            player.getElo().setEloValue(EloType.E5V5, newElo);
            modified = true;
        }
    } else if (eloType != null) {
        throw new MissingRequestArgumentException();
    }
    if (save && modified) {
        eloService.savePlayer(player);
    }

    return player;
}