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:bammerbom.ultimatecore.bukkit.resources.utils.BossbarUtil.java

public static Method getMethod(Class<?> cl, String method, Integer args) {
    for (Method m : cl.getMethods()) {
        if ((m.getName().equals(method)) && (args.equals(new Integer(m.getParameterTypes().length)))) {
            return m;
        }//from w  w  w  . java  2 s .  com
    }
    return null;
}

From source file:com.tethrnet.manage.util.SSHUtil.java

/**
 * return the next instance id based on ids defined in the session map
 *
 * @param sessionId      session id//from w w  w .  j a v a 2 s . c o  m
 * @param userSessionMap user session map
 * @return
 */
private static int getNextInstanceId(Long sessionId, Map<Long, UserSchSessions> userSessionMap) {

    Integer instanceId = 1;
    if (userSessionMap.get(sessionId) != null) {

        for (Integer id : userSessionMap.get(sessionId).getSchSessionMap().keySet()) {
            if (!id.equals(instanceId)) {

                if (userSessionMap.get(sessionId).getSchSessionMap().get(instanceId) == null) {
                    return instanceId;
                }
            }
            instanceId = instanceId + 1;
        }
    }
    return instanceId;

}

From source file:Main.java

/**
 * <p>Converts an Integer to a Boolean specifying the conversion values.</p>
 *
 * <p>NOTE: This returns null and will throw a NullPointerException if autoboxed to a boolean. </p>
 *
 * <pre>//from w w  w . j  a v a2  s .  c  om
 *   BooleanUtils.toBooleanObject(Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(2), Integer.valueOf(3)) = Boolean.TRUE
 *   BooleanUtils.toBooleanObject(Integer.valueOf(2), Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3)) = Boolean.FALSE
 *   BooleanUtils.toBooleanObject(Integer.valueOf(3), Integer.valueOf(1), Integer.valueOf(2), Integer.valueOf(3)) = null
 * </pre>
 *
 * @param value  the Integer to convert
 * @param trueValue  the value to match for {@code true}, may be {@code null}
 * @param falseValue  the value to match for {@code false}, may be {@code null}
 * @param nullValue  the value to to match for {@code null}, may be {@code null}
 * @return Boolean.TRUE, Boolean.FALSE, or {@code null}
 * @throws IllegalArgumentException if no match
 */
public static Boolean toBooleanObject(final Integer value, final Integer trueValue, final Integer falseValue,
        final Integer nullValue) {
    if (value == null) {
        if (trueValue == null) {
            return Boolean.TRUE;
        }
        if (falseValue == null) {
            return Boolean.FALSE;
        }
        if (nullValue == null) {
            return null;
        }
    } else if (value.equals(trueValue)) {
        return Boolean.TRUE;
    } else if (value.equals(falseValue)) {
        return Boolean.FALSE;
    } else if (value.equals(nullValue)) {
        return null;
    }
    // no match
    throw new IllegalArgumentException("The Integer did not match any specified value");
}

From source file:de.tudarmstadt.ukp.dkpro.discourse.pdtbparser.PDTBDiscourseAnnotator.java

private static DiscourseAttribution findDiscourseAttribution(List<DiscourseAttribution> list, Integer attrId) {
    DiscourseAttribution result = null;//from w  ww . j a v  a2  s .  co m

    for (DiscourseAttribution attribution : list) {
        if (attrId.equals(attribution.getAttributeId())) {
            // we found it
            if (result != null) {
                throw new IllegalStateException("Two same attributions are in the list with attrID " + attrId);
            }

            result = attribution;
        }
    }

    if (result == null) {
        System.out.println("Cannot look-up opening attribution for relationId: " + attrId);
    }

    return result;
}

From source file:com.acc.storefront.tags.Functions.java

protected static boolean doesPromotionExistForOrderEntry(final List<PromotionResultData> productPromotions,
        final int entryNumber) {
    if (productPromotions != null && !productPromotions.isEmpty()) {
        final Integer entryNumberToFind = Integer.valueOf(entryNumber);

        for (final PromotionResultData productPromotion : productPromotions) {
            if (StringUtils.isNotBlank(productPromotion.getDescription())) {
                final List<PromotionOrderEntryConsumedData> consumedEntries = productPromotion
                        .getConsumedEntries();
                if (consumedEntries != null && !consumedEntries.isEmpty()) {
                    for (final PromotionOrderEntryConsumedData consumedEntry : consumedEntries) {
                        if (entryNumberToFind.equals(consumedEntry.getOrderEntryNumber())) {
                            return true;
                        }/* w  w w.  ja  va 2s .  com*/
                    }
                }
            }
        }
    }
    return false;
}

From source file:com.aurel.track.admin.customize.lists.systemOption.IssueTypeBL.java

/**
 * Create an entry with the new issue type for each  
 * project type in the associated TPCATEGORY table, 
 * which have at least one other issue type assigned.
 * This is to initially enable a new issue type
 * for all project types. Users may then go and remove
 * certain entries so that the new value is only enabled for some
 * project types.//from w  ww  .  j a v  a2  s.c  o  m
 * @param newIssueTypeID
 */
private static void addFilterAssignments(Integer newIssueTypeID) {
    List<TPlistTypeBean> plistTypeBeanList = pIssueTypeDAO.loadAll();
    Set<Integer> projectTypesWithIssueTypes = new HashSet<Integer>();
    //probably not needed if this is called only by creating a new issue type 
    Set<Integer> projectTypesWithThisIssueType = new HashSet<Integer>();
    for (TPlistTypeBean plistTypeBean : plistTypeBeanList) {
        Integer projectTypeID = plistTypeBean.getProjectType();
        Integer issuetypeID = plistTypeBean.getCategory();
        if (projectTypeID != null && issuetypeID != null) {
            projectTypesWithIssueTypes.add(projectTypeID);
            if (issuetypeID.equals(newIssueTypeID)) {
                projectTypesWithThisIssueType.add(projectTypeID);
            }
        }
    }
    for (Integer projectTypeID : projectTypesWithIssueTypes) {
        //do not add for the same issue type again (not the case for new issue types)
        if (!projectTypesWithThisIssueType.contains(projectTypeID)) {
            insertAssignment(projectTypeID, newIssueTypeID);
        }
    }
}

From source file:de.tudarmstadt.ukp.dkpro.discourse.pdtbparser.PDTBDiscourseAnnotator.java

/**
 * Looks-up existing discourse argument from the list given the parameters
 *
 * @param list           list//from  w ww  .jav  a 2 s . c o  m
 * @param relationId     relation id
 * @param argumentNumber argument number
 * @return discourse argument (never null)
 * @throws java.lang.IllegalStateException if the discourse argument is not in list or there
 *                                         are more than one with with the parameters
 */
private static DiscourseArgument findDiscourseArgument(List<DiscourseArgument> list, Integer relationId,
        Integer argumentNumber) {
    DiscourseArgument result = null;

    for (DiscourseArgument argument : list) {
        if (relationId.equals(argument.getParentRelationId())
                && argumentNumber.equals(argument.getArgumentNumber())) {
            // we found it
            if (result != null) {
                throw new IllegalStateException("Two same arguments are in the list with relationId "
                        + relationId + " and argumentNumber " + argumentNumber);
            }

            result = argument;
        }
    }

    if (result == null) {
        System.out.println("Cannot look-up opening argument for relationId: " + relationId
                + ", argumentNumber: " + argumentNumber);
        //            System.out.println(list);
        //            throw new IllegalArgumentException("No such argument found in list.");
    }

    return result;
}

From source file:de.iteratec.iteraplan.businesslogic.reports.query.postprocessing.HideSubInformationSystemReleasesWithConnectionMergingStrategy.java

/**
 * Merges two interfaces which connect the same IS releases.
 * //  w ww.  j  a  v a  2 s  .c om
 * @param original
 *          The original interface. This is an in-out parameter.
 * @param duplicate
 *          The duplicate interface.
 */
private static void mergeInterfaces(InformationSystemInterface original, InformationSystemInterface duplicate) {

    Integer origFromIsrId = original.getInformationSystemReleaseA().getId();
    Integer origToIsrId = original.getInformationSystemReleaseB().getId();

    Integer duplFromIsrId = duplicate.getInformationSystemReleaseA().getId();
    Integer duplToIsrId = duplicate.getInformationSystemReleaseB().getId();

    if (origFromIsrId.equals(duplFromIsrId) && origToIsrId.equals(duplToIsrId)) {
        original.setTransports(mergeTransports(original.getTransports(), duplicate.getTransports(), true));
    } else if (origFromIsrId.equals(duplToIsrId) && origToIsrId.equals(duplFromIsrId)) {
        original.setTransports(mergeTransports(original.getTransports(), duplicate.getTransports(), false));
    } else {
        throw new IteraplanTechnicalException(IteraplanErrorMessages.INTERNAL_ERROR);
    }
}

From source file:com.aurel.track.lucene.LuceneUtil.java

/**
 * Whether to add the highlighted field for this item type
 * @param itemTypeID/*  w  w w.  j av  a  2 s.  c  o m*/
 * @return
 */
public static boolean isHighlightedItemType(Integer itemTypeID) {
    boolean withHighlighter = false;
    if (itemTypeID != null) {
        TListTypeBean itemTypeBean = LookupContainer.getItemTypeBean(itemTypeID);
        if (itemTypeBean != null) {
            Integer typeFlag = itemTypeBean.getTypeflag();
            if (typeFlag != null && (typeFlag.equals(TListTypeBean.TYPEFLAGS.DOCUMENT)
                    || typeFlag.equals(TListTypeBean.TYPEFLAGS.DOCUMENT_SECTION))) {
                withHighlighter = true;
            }
        }
    }
    return withHighlighter;
}

From source file:de.hybris.platform.ytelcoacceleratorstorefront.tags.Functions.java

/**
 * Check if product promotions are assigned to the given orderEntry
 *///from  w ww  .ja va 2s .  c  o  m
protected static boolean doesPromotionExistForOrderEntry(final List<PromotionResultData> productPromotions,
        final int entryNumber) {
    if (productPromotions != null && !productPromotions.isEmpty()) {
        final Integer entryNumberToFind = Integer.valueOf(entryNumber);

        for (final PromotionResultData productPromotion : productPromotions) {
            if (StringUtils.isNotBlank(productPromotion.getDescription())) {
                final List<PromotionOrderEntryConsumedData> consumedEntries = productPromotion
                        .getConsumedEntries();
                if (consumedEntries != null && !consumedEntries.isEmpty()) {
                    for (final PromotionOrderEntryConsumedData consumedEntry : consumedEntries) {
                        if (entryNumberToFind.equals(consumedEntry.getOrderEntryNumber())) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}