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.flexive.shared.value.FxValue.java

/**
 * Compare value data with another FxValue for equality
 *
 * @param otherValue other FxValue to compare
 * @return equal/*www . j a v a2s .com*/
 */
private boolean equalsValueData(FxValue<?, ?> otherValue) {
    if (hasValueData() != otherValue.hasValueData())
        return false;
    if (isMultiLanguage() != otherValue.isMultiLanguage())
        return false;
    if (!hasValueData())
        return true;
    if (isMultiLanguage()) {
        // check if value data is equal, taking into account that the "default value" (the main valueData field) can
        // be used as fallback. The other direction (otherValue -> this) does not need to be checked, because if the number
        // of translations does not match, the equality check will return false anyway.

        final Map<Long, Integer> thisML = multiLangData != null ? multiLangData
                : Collections.<Long, Integer>emptyMap();
        final Map<Long, Integer> otherML = otherValue.multiLangData != null ? otherValue.multiLangData
                : Collections.<Long, Integer>emptyMap();
        for (Entry<Long, Integer> entry : thisML.entrySet()) {
            final Integer value = entry.getValue();
            final Integer other = otherML.get(entry.getKey());
            final Integer checkValue = value == null ? valueData : value;
            final Integer checkOther = other == null ? otherValue.valueData : other;
            if (checkValue != null && !checkValue.equals(checkOther)) {
                return false;
            } else if (checkValue == null && checkOther != null) {
                return false;
            }
        }
        return true;
    } else {
        return valueData.equals(otherValue.valueData);
    }
}

From source file:com.gst.portfolio.loanaccount.loanschedule.service.LoanScheduleAssembler.java

private void validateRepaymentFrequencyIsSameAsMeetingFrequency(final Integer meetingFrequency,
        final Integer repaymentFrequency, final Integer meetingInterval, final Integer repaymentInterval) {
    // meeting with daily frequency should allow loan products with any
    // frequency.
    if (!PeriodFrequencyType.DAYS.getValue().equals(meetingFrequency)) {
        // repayment frequency must match with meeting frequency
        if (!meetingFrequency.equals(repaymentFrequency)) {
            throw new MeetingFrequencyMismatchException("loanapplication.repayment.frequency",
                    "Loan repayment frequency period must match that of meeting frequency period",
                    repaymentFrequency);
        } else if (meetingFrequency.equals(repaymentFrequency)) {
            // repayment frequency is same as meeting frequency repayment
            // interval should be same or multiple of meeting interval
            if (repaymentInterval % meetingInterval != 0) {
                // throw exception: Loan product frequency/interval
                throw new MeetingFrequencyMismatchException("loanapplication.repayment.interval",
                        "Loan repayment repaid every # must equal or multiple of meeting interval "
                                + meetingInterval,
                        meetingInterval, repaymentInterval);
            }// w  ww  .  ja  v  a2s. c om
        }
    }
}

From source file:edu.ku.brc.specify.conversion.ConvertTaxonHelper.java

/**
 * //w  ww. j ava  2  s  . c o m
 */
public void doConvert() {
    getTaxonTreesTypesInUse();

    convertAllTaxonTreeDefs();
    convertTaxonTreeDefSeparators();

    convertTaxonRecords(); // converts all the taxon records

    HashMap<Integer, Integer> dispTxnRootHash = new HashMap<Integer, Integer>();
    for (CollectionInfo colInfo : collectionInfoList) {
        Integer txnRootId = dispTxnRootHash.get(colInfo.getDisciplineId());
        if (txnRootId == null) {
            dispTxnRootHash.put(colInfo.getDisciplineId(), colInfo.getTaxonNameId());

        } else if (!txnRootId.equals(colInfo.getTaxonNameId())) {
            UIRegistry.showError("Two (or more) Disciplines have different Taxon Root Id records.  Dsp["
                    + colInfo.getDisciplineId() + "]  Prev RootId[" + txnRootId + "] New RootId["
                    + colInfo.getTaxonNameId() + "]");
        }
    }

    for (Integer dispId : dispTxnRootHash.keySet()) {
        Pair<TaxonTreeDef, Discipline> dispTxn = doTaxonForCollection(dispId, dispTxnRootHash.get(dispId));
        if (dispTxn != null) {
            for (CollectionInfo colInfo : collectionInfoList) {
                if (colInfo.getDisciplineId().equals(dispTxn.second.getId())) {
                    colInfo.setTaxonTreeDef(dispTxn.first);
                }
            }
        }
    }
    //assignTreeDefToDiscipline();
}

From source file:com.hbc.api.fund.biz.service.FundWithdrawService.java

public List<FundWithdrawal> getFundWithdrawListByProcessStatus(FundWithDrawQueryBean queryBean) {
    FundWithdrawalExample criteria = new FundWithdrawalExample();
    FundWithdrawalExample.Criteria cc = criteria.createCriteria();
    Integer processStatus = queryBean.getProcessStatus();
    cc.andProcessStatusEqualTo(processStatus);

    if (StringUtils.isNoneBlank(queryBean.getGuideNo())) {
        cc.andGuideNoEqualTo(queryBean.getGuideNo());
    }// w w  w  .  j av  a2 s.  c  om

    if (StringUtils.isNoneBlank(queryBean.getGuideName())) {
        cc.andGuideNameLike(
                new StringBuilder().append("%").append(queryBean.getGuideName()).append("%").toString());
    }

    if (queryBean.getProcessStatus() == FundWithDrawQueryBean.AUTO_PROC) {
        if (queryBean.getDrawStatus() == null) {
            List<Integer> in = new ArrayList<Integer>();
            in.add(FundDrawStatus.APPLY.value);
            in.add(FundDrawStatus.HAVE_TRANSFERED.value);
            in.add(FundDrawStatus.AUTO_WITHDRAW_FAILED.value);
            in.add(FundDrawStatus.AUTO_WITHDRAW_APPLIED.value);
            cc.andDrawStatusIn(in);
        } else {
            cc.andDrawStatusEqualTo(queryBean.getDrawStatus());
        }
    }

    Page page = new Page(queryBean.getOffset(), queryBean.getLimit());
    criteria.setPage(page);

    //????????????
    if (processStatus.equals(FundProcessStatus.INIT.value)
            || processStatus.equals(FundProcessStatus.AUTO_PROCESS.value)) {
        criteria.setOrderByClause("apply_time asc");
    } else if (processStatus.equals(FundProcessStatus.PROCESSED.value)) {
        criteria.setOrderByClause("update_time desc");
    }

    return fundWithdrawMapper.selectByExample(criteria);
}

From source file:edu.upenn.cis.orchestra.workloadgenerator.Generator.java

public void findSimpleCycles(List<List<Integer>> cycles, List<List<Object>> mappings) {
    // First, index the edges
    List<List<Integer>> edges = new ArrayList<List<Integer>>();

    for (int i = 0; i < _peers.size(); i++) {
        edges.add(new ArrayList<Integer>());
    }/* w w w .ja  v  a  2s.  c om*/

    for (List<Object> thisMapping : mappings) {
        edges.get((Integer) thisMapping.get(0)).add((Integer) thisMapping.get(1));
    }

    for (List<Integer> thisEdge : edges) {
        Collections.sort(thisEdge);
    }

    // Find simple cycles as follows:
    // - Handle the peers in order
    // - Find simple cycles where the smallest node in the cycle
    // is the peer
    cycles.clear();
    for (int i = 0; i < _peers.size(); i++) {
        Deque<List<Integer>> paths = new ArrayDeque<List<Integer>>();
        paths.push(new ArrayList<Integer>());
        paths.peek().add(i);
        while (0 != paths.size()) {
            List<Integer> path = paths.pop();
            for (Integer j : edges.get(path.get(path.size() - 1))) {
                if (j.equals(i)) {
                    List<Integer> cycle = new ArrayList<Integer>();
                    cycle.addAll(path);
                    cycle.add(j);
                    cycles.add(cycle);
                } else if (j > i && !path.contains(j)) {
                    List<Integer> newPath = new ArrayList<Integer>();
                    newPath.addAll(path);
                    newPath.add(j);
                    paths.push(newPath);
                }
            }
        }
    }
}

From source file:com.gst.portfolio.savings.service.SavingsAccountWritePlatformServiceJpaRepositoryImpl.java

@Transactional
@Override// w  ww.  j a  va  2s.co  m
public CommandProcessingResult addSavingsAccountCharge(final JsonCommand command) {

    this.context.authenticatedUser();
    final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
    final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
            .resource(SAVINGS_ACCOUNT_RESOURCE_NAME);

    final Long savingsAccountId = command.getSavingsId();
    this.savingsAccountChargeDataValidator.validateAdd(command.json());

    final SavingsAccount savingsAccount = this.savingAccountAssembler.assembleFrom(savingsAccountId);
    checkClientOrGroupActive(savingsAccount);

    final Locale locale = command.extractLocale();
    final String format = command.dateFormat();
    final DateTimeFormatter fmt = StringUtils.isNotBlank(format)
            ? DateTimeFormat.forPattern(format).withLocale(locale)
            : DateTimeFormat.forPattern("dd MM yyyy");

    final Long chargeDefinitionId = command.longValueOfParameterNamed(chargeIdParamName);
    final Charge chargeDefinition = this.chargeRepository.findOneWithNotFoundDetection(chargeDefinitionId);

    Integer chargeTimeType = chargeDefinition.getChargeTimeType();
    LocalDate dueAsOfDateParam = command.localDateValueOfParameterNamed(dueAsOfDateParamName);
    if ((chargeTimeType.equals(ChargeTimeType.WITHDRAWAL_FEE.getValue())
            || chargeTimeType.equals(ChargeTimeType.SAVINGS_NOACTIVITY_FEE.getValue()))
            && dueAsOfDateParam != null) {
        baseDataValidator.reset().parameter(dueAsOfDateParamName).value(dueAsOfDateParam.toString(fmt))
                .failWithCodeNoParameterAddedToErrorCode(
                        "charge.due.date.is.invalid.for." + ChargeTimeType.fromInt(chargeTimeType).getCode());
    }
    final SavingsAccountCharge savingsAccountCharge = SavingsAccountCharge.createNewFromJson(savingsAccount,
            chargeDefinition, command);

    if (savingsAccountCharge.getDueLocalDate() != null) {
        // transaction date should not be on a holiday or non working day
        if (!this.configurationDomainService.allowTransactionsOnHolidayEnabled() && this.holidayRepository
                .isHoliday(savingsAccount.officeId(), savingsAccountCharge.getDueLocalDate())) {
            baseDataValidator.reset().parameter(dueAsOfDateParamName)
                    .value(savingsAccountCharge.getDueLocalDate().toString(fmt))
                    .failWithCodeNoParameterAddedToErrorCode("charge.due.date.is.on.holiday");
        }

        if (!this.configurationDomainService.allowTransactionsOnNonWorkingDayEnabled()
                && !this.workingDaysRepository.isWorkingDay(savingsAccountCharge.getDueLocalDate())) {
            baseDataValidator.reset().parameter(dueAsOfDateParamName)
                    .value(savingsAccountCharge.getDueLocalDate().toString(fmt))
                    .failWithCodeNoParameterAddedToErrorCode("charge.due.date.is.a.nonworking.day");
        }
    }
    if (!dataValidationErrors.isEmpty()) {
        throw new PlatformApiDataValidationException(dataValidationErrors);
    }

    savingsAccount.addCharge(fmt, savingsAccountCharge, chargeDefinition);
    this.savingsAccountChargeRepository.save(savingsAccountCharge);
    this.savingAccountRepositoryWrapper.saveAndFlush(savingsAccount);
    return new CommandProcessingResultBuilder() //
            .withEntityId(savingsAccountCharge.getId()) //
            .withOfficeId(savingsAccount.officeId()) //
            .withClientId(savingsAccount.clientId()) //
            .withGroupId(savingsAccount.groupId()) //
            .withSavingsId(savingsAccountId) //
            .build();
}

From source file:com.aurel.track.fieldType.runtime.custom.select.CustomDependentSelectRT.java

/**
 * Loads the datasource for the matcher/*from   w w w.jav  a  2 s .com*/
 * used by select fields to get the possible values
 * It will be called from both field expressions and upper selects 
 * The value can be a list for simple select or a map of lists for composite selects or a tree
 * @param matcherValue
 * @param matcherDatasourceContext the data source may be project dependent. 
 * @param parameterCode for composite selects
 * @return the datasource (list or tree)
 */
@Override
public Object getMatcherDataSource(IMatcherValue matcherValue,
        MatcherDatasourceContext matcherDatasourceContext, Integer parameterCode) {
    Map<Integer, Integer[]> actualValuesMap = null;
    Locale locale = matcherDatasourceContext.getLocale();
    try {
        actualValuesMap = (Map<Integer, Integer[]>) matcherValue.getValue();
    } catch (Exception e) {
        LOGGER.warn("ValueModified: converting the qnode values to map failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (actualValuesMap == null || actualValuesMap.isEmpty()) {
        return new ArrayList<IBeanID>();
    }
    Integer parentIntValue = null;
    try {
        Integer[] parentIntArr = actualValuesMap.get(parentID);
        if (parentIntArr != null && parentIntArr.length > 0) {
            parentIntValue = parentIntArr[0];
        }
    } catch (Exception e) {
        LOGGER.warn("Converting the parent value to Integer failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    Integer childIntValue = null;
    try {
        Integer[] childIntArr = actualValuesMap.get(parameterCode);
        if (childIntArr != null && childIntArr.length > 0) {
            childIntValue = childIntArr[0];
        }
    } catch (Exception e) {
        LOGGER.warn("Converting the child value to Integer failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    List<ILabelBean> possibleValues = null;
    if (parentIntValue != null) {
        boolean isPartialMatch = false;
        if (parentIntValue.equals(CompositeSelectMatcherRT.ANY_FROM_LEVEL)
                || parentIntValue.equals(CompositeSelectMatcherRT.NONE_FROM_LEVEL)) {
            isPartialMatch = true;
        }
        if (isPartialMatch) {
            actualValuesMap.put(parameterCode, new Integer[] { parentIntValue });
            possibleValues = new LinkedList<ILabelBean>();
            ILabelBean partialMatch = getPartialMatchEntry(matcherValue, locale);
            if (partialMatch != null) {
                possibleValues.add(0, partialMatch);
            }
            //then previous level is partial match, the child list should contain only a partial match
        } else {
            TOptionBean parentOptionBean = OptionBL.loadByPrimaryKey(parentIntValue);
            if (parentOptionBean != null) {
                Integer parentListID = parentOptionBean.getList();
                TListBean childListBean = ListBL.getChildList(parentListID, childNumber);
                if (childListBean != null) {
                    possibleValues = LocalizeUtil.localizeDropDownList(
                            optionDAO.loadActiveByListAndParentOrderedBySortorder(childListBean.getObjectID(),
                                    parentIntValue),
                            locale);
                    ILabelBean partialMatch = getPartialMatchEntry(matcherValue, locale);
                    if (partialMatch != null) {
                        if (possibleValues == null) {
                            possibleValues = new LinkedList<ILabelBean>();
                        }
                        possibleValues.add(0, partialMatch);
                    }
                    if (possibleValues != null && !possibleValues.isEmpty()) {
                        if (childIntValue == null) {
                            //preselect to the first if not yet selected
                            actualValuesMap.put(parameterCode,
                                    new Integer[] { possibleValues.get(0).getObjectID() });
                        } else {
                            boolean found = false;
                            Iterator<ILabelBean> iterator = possibleValues.iterator();
                            while (iterator.hasNext()) {
                                ILabelBean beanID = iterator.next();
                                if (childIntValue.equals(beanID.getObjectID())) {
                                    found = true;
                                    break;
                                }
                            }
                            if (!found) {
                                actualValuesMap.put(parameterCode,
                                        new Integer[] { possibleValues.get(0).getObjectID() });
                            }
                        }
                    } else {
                        actualValuesMap.put(parameterCode, null);
                    }
                }
            }
        }
    }
    if (possibleValues == null) {
        return new ArrayList<IBeanID>();
    } else {
        return possibleValues;
    }
}

From source file:edu.ku.brc.specify.tasks.ReportsBaseTask.java

/**
 * @param mimeType//from ww  w . j  a va  2s. com
 * @param reportType
 * @param defaultIcon
 * @param classTableId
 * @return List of command defs for valid report AppResources.
 * 
 * Needed to 'override' static method in BaseTask to deal with imported reports.
 */
protected List<TaskCommandDef> getAppResCommandsByMimeType(final String mimeType, final String reportType,
        final String defaultIcon, final Integer classTableId)

{
    List<TaskCommandDef> result = new LinkedList<TaskCommandDef>();
    Vector<Integer> excludedTableIds = new Vector<Integer>();
    excludedTableIds.add(79);
    Vector<String> subReports = new Vector<String>();
    for (AppResourceIFace ap : AppContextMgr.getInstance().getResourceByMimeType(mimeType)) {
        Properties params = ap.getMetaDataMap();

        Integer appId = ap instanceof SpAppResource ? ((SpAppResource) ap).getId() : null;
        if (appId != null) {
            params.put("spappresourceid", appId);
        }

        String tableid = params.getProperty("tableid"); //$NON-NLS-1$

        if (StringUtils.isNotEmpty(tableid)) {
            String subReps = params.getProperty("subreports");
            if (subReps != null) {
                String[] subRepNames = StringUtils.split(subReps, ",");
                for (String subRepName : subRepNames) {
                    subReports.add(subRepName.trim());
                }
            }
            String rptType = params.getProperty("reporttype"); //$NON-NLS-1$
            Integer tblId = Integer.parseInt(tableid);
            if (excludedTableIds.indexOf(tblId) == -1 && (classTableId == null || tblId.equals(classTableId))
                    && (StringUtils.isEmpty(reportType)
                            || (StringUtils.isNotEmpty(rptType) && reportType.equals(rptType)))) {
                params.put("name", ap.getName()); //$NON-NLS-1$
                params.put("title", ap.getDescription() == null ? ap.getName() : ap.getDescription()); //$NON-NLS-1$
                params.put("file", ap.getName()); //$NON-NLS-1$
                params.put("mimetype", mimeType); //$NON-NLS-1$
                Object param = params.get("isimport");
                if (param != null && param.equals("1")) {
                    params.put("appresource", ap);
                }
                param = params.get("hasrsdropparam");
                if (param != null) {
                    params.put(RECORDSET_PARAM, param);
                }
                String localIconName = params.getProperty("icon"); //$NON-NLS-1$
                if (StringUtils.isEmpty(localIconName)) {
                    localIconName = defaultIcon;
                }
                result.add(new TaskCommandDef(ap.getDescription(), localIconName, params));
            }
        }
    }
    if (subReports.size() > 0) {
        for (int r = result.size() - 1; r >= 0; r--) {
            TaskCommandDef def = result.get(r);
            if (subReports.indexOf(def.getName()) != -1) {
                result.remove(r);
            }

        }
    }
    return result;
}

From source file:com.aurel.track.accessControl.AccessBeans.java

/**
 * Filters out the cost beans from the reportBeanWithHistory objects when it
 * is not the person's own cost and he/she has no right to see the others'
 * costs// w w  w.  ja  v a2 s.  c o  m
 *
 * @param costBeans
 * @param personID
 * @param workItemBeansMap
 */
public static void filterCostBeans(List<TCostBean> costBeans, Integer personID,
        Map<Integer, TWorkItemBean> workItemBeansMap) {
    if (personID == null || costBeans == null || costBeans.isEmpty()) {
        return;
    }
    Map<Integer, Set<Integer>> projectToIssueTypesMap = getProjectToIssueTypesMap(workItemBeansMap.values());
    List<Integer> fieldIDs = new LinkedList<Integer>();
    fieldIDs.add(FieldsRestrictionsToRoleBL.PSEUDO_COLUMNS.ALL_EXPENSES);
    Map<Integer, Map<Integer, Map<Integer, Integer>>> fieldRestrictions = getFieldRestrictions(personID,
            projectToIssueTypesMap, fieldIDs, false);
    for (Iterator<TCostBean> itrCostBeans = costBeans.iterator(); itrCostBeans.hasNext();) {
        TCostBean costBean = itrCostBeans.next();
        Integer changedBy = costBean.getChangedByID();
        if (changedBy != null && !changedBy.equals(personID)) {
            // my expenses are always visible
            Integer workItemID = costBean.getWorkItemID();
            TWorkItemBean workItemBean = workItemBeansMap.get(workItemID);
            Integer projectID = workItemBean.getProjectID();
            Integer issueTypeID = workItemBean.getListTypeID();
            Map<Integer, Map<Integer, Integer>> issueTypeRestrictions = fieldRestrictions.get(projectID);
            Map<Integer, Integer> hiddenFields = null;
            if (issueTypeRestrictions != null) {
                hiddenFields = issueTypeRestrictions.get(issueTypeID);
            }
            if (hiddenFields != null
                    && hiddenFields.containsKey(FieldsRestrictionsToRoleBL.PSEUDO_COLUMNS.ALL_EXPENSES)) {
                itrCostBeans.remove();
            }
        }
    }
}

From source file:com.aurel.track.accessControl.AccessBeans.java

/**
 * Filters out the cost beans from the reportBeanWithHistory objects when it
 * is not the person's own cost and he/she has no right to see the others'
 * costs/*ww  w.  j a  v  a2s .c  o m*/
 *
 * @param budgetBeans
 * @param personID
 * @param workItemBeansMap
 */
public static void filterBudgetBeans(List<TBudgetBean> budgetBeans, Integer personID,
        Map<Integer, TWorkItemBean> workItemBeansMap) {
    if (personID == null || budgetBeans == null || budgetBeans.isEmpty()) {
        return;
    }
    Map<Integer, Set<Integer>> projectToIssueTypesMap = getProjectToIssueTypesMap(workItemBeansMap.values());
    List<Integer> fieldIDs = new LinkedList<Integer>();
    fieldIDs.add(FieldsRestrictionsToRoleBL.PSEUDO_COLUMNS.PLAN);
    fieldIDs.add(FieldsRestrictionsToRoleBL.PSEUDO_COLUMNS.BUDGET);
    Map<Integer, Map<Integer, Map<Integer, Integer>>> fieldRestrictions = getFieldRestrictions(personID,
            projectToIssueTypesMap, fieldIDs, false);
    for (Iterator<TBudgetBean> iterator = budgetBeans.iterator(); iterator.hasNext();) {
        TBudgetBean budgetBean = iterator.next();
        Integer changedBy = budgetBean.getChangedByID();
        if (changedBy != null && !changedBy.equals(personID)) {
            Integer budgetType = budgetBean.getBudgetType();
            Integer workItemID = budgetBean.getWorkItemID();
            TWorkItemBean workItemBean = workItemBeansMap.get(workItemID);
            Integer projectID = workItemBean.getProjectID();
            Integer issueTypeID = workItemBean.getListTypeID();
            Map<Integer, Map<Integer, Integer>> issueTypeRestrictions = fieldRestrictions.get(projectID);
            Map<Integer, Integer> hiddenFields = null;
            if (issueTypeRestrictions != null) {
                hiddenFields = issueTypeRestrictions.get(issueTypeID);
            }
            if (hiddenFields != null) {
                if ((budgetType == null || TBudgetBean.BUDGET_TYPE.PLANNED_VALUE.equals(budgetType))
                        && hiddenFields.containsKey(FieldsRestrictionsToRoleBL.PSEUDO_COLUMNS.PLAN)) {
                    iterator.remove();
                } else {
                    if ((TBudgetBean.BUDGET_TYPE.BUDGET.equals(budgetType))
                            && hiddenFields.containsKey(FieldsRestrictionsToRoleBL.PSEUDO_COLUMNS.BUDGET)) {
                        iterator.remove();
                    }
                }
            }
        }
    }
}