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.esofthead.mycollab.vaadin.web.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 {/*w w  w  .  j  a v  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:com.act.analysis.surfactant.AtomSplit.java

public static Pair<AtomSplit, AtomSplit> computePlaneSplitsForIntersectingAtom(Collection<Integer> leftAtoms,
        Collection<Integer> rightAtoms, Integer planeIntersectingAtom, logPPlugin plugin,
        Map<Integer, Integer> surfaceComponentCounts) {

    /* Compute variants of the split with the current atom on either side of its plane.
     */* ww w.  j a va2  s.  c  o m*/
     * This isn't the most clever way to compute the optimal planes, since adjacent split points will end up creating
     * one redundant plane with each computation (if a and b are adjacent, a to the left of the border and b to the
     * right create the same split sets).  However, it's easy to reason about the correctness of this approach, so
     * we'll just live with the inefficiency for now.
     *
     * TODO: extend this to handle an arbitrary set of co-planar points that define the split, and apply the same
     * technique to all triples of atoms.
     * */

    AtomSplit ps = new AtomSplit();
    ps.leftIndices = new HashSet<>(leftAtoms);
    ps.rightIndices = new HashSet<>(rightAtoms);

    for (Integer a : leftAtoms) {
        if (planeIntersectingAtom.equals(a)) {
            // Skip the split point, though it could contribute to the "best" solution.
            continue;
        }
        Double logP = plugin.getAtomlogPIncrement(a);
        Double weightedLogP = logP * surfaceComponentCounts.get(a).doubleValue();
        ps.leftSum += logP;
        ps.weightedLeftSum += weightedLogP;

        if (logP < ps.leftMin) {
            ps.leftMin = logP;
        }
        if (logP > ps.leftMax) {
            ps.leftMax = logP;
        }

        if (logP >= 0.000) {
            ps.leftPosCount++;
        } else {
            ps.leftNegCount++;
        }
    }
    for (Integer a : rightAtoms) {
        if (planeIntersectingAtom.equals(a)) {
            continue;
        }
        Double logP = plugin.getAtomlogPIncrement(a);
        Double weightedLogP = logP * surfaceComponentCounts.get(a);
        ps.rightSum += logP;
        ps.weightedRightSum += weightedLogP;

        if (logP < ps.rightMin) {
            ps.rightMin = logP;
        }
        if (logP > ps.rightMax) {
            ps.rightMax = logP;
        }

        if (logP >= 0.000) {
            ps.rightPosCount++;
        } else {
            ps.rightNegCount++;
        }
    }

    // Create variants with this point added to left and right sides of split plane.
    AtomSplit leftVariant = ps;
    AtomSplit rightVariant = new AtomSplit(ps);
    Double logP = plugin.getAtomlogPIncrement(planeIntersectingAtom);
    Double weightedLogP = logP * surfaceComponentCounts.get(planeIntersectingAtom).doubleValue();

    leftVariant.leftIndices.add(planeIntersectingAtom);
    leftVariant.leftSum += logP;
    leftVariant.weightedLeftSum += weightedLogP;
    if (logP >= 0.000) {
        leftVariant.leftPosCount++;
    } else {
        leftVariant.leftNegCount++;
    }
    if (logP < leftVariant.leftMin) {
        leftVariant.leftMin = logP;
    }
    if (logP > leftVariant.leftMax) {
        leftVariant.leftMax = logP;
    }

    rightVariant.rightIndices.add(planeIntersectingAtom);
    rightVariant.rightSum += logP;
    rightVariant.weightedRightSum += weightedLogP;
    if (logP >= 0.000) {
        rightVariant.rightPosCount++;
    } else {
        rightVariant.rightNegCount++;
    }
    if (logP < rightVariant.rightMin) {
        rightVariant.rightMin = logP;
    }
    if (logP > rightVariant.rightMax) {
        rightVariant.rightMax = logP;
    }

    return Pair.of(leftVariant, rightVariant);
}

From source file:net.sourceforge.fenixedu.presentationTier.backBeans.student.enrolment.DisplayEvaluationsForStudentToEnrol.java

public String getEvaluationTypeString() {
    final Integer type = getEvaluationType();
    if (type != null && type.equals(EXAMS)) {
        return "net.sourceforge.fenixedu.domain.Exam";
    } else if (type != null && type.equals(WRITTENTESTS)) {
        return "net.sourceforge.fenixedu.domain.WrittenTest";
    }/*  w ww .  j  a va 2s. c om*/
    return "";
}

From source file:com.aurel.track.fieldType.runtime.matchers.converter.CompositSelectMatcherConverter.java

/**
 * Convert a string from displayStringMap to object value
 * Called after submitting the filter's form
 * @param displayStringMap/*from www .j a va 2  s .c o m*/
 * @param fieldID
 * @param locale
 * @param matcherRelation
 * @return
 */
@Override
public Object fromDisplayString(Map<String, String> displayStringMap, Integer fieldID, Locale locale,
        Integer matcherRelation) {
    if (displayStringMap == null) {
        return null;
    }
    if (matcherRelation != null) {
        switch (matcherRelation.intValue()) {
        case MatchRelations.EQUAL:
        case MatchRelations.NOT_EQUAL:
        case MatchRelations.PARTIAL_MATCH:
        case MatchRelations.PARTIAL_NOTMATCH:
            //it should be sorted map because of toXMLString(), 
            //in xml the values should be serialized in the right order
            SortedMap<Integer, Integer[]> actualValuesMap = new TreeMap<Integer, Integer[]>();
            Iterator<String> iterator = displayStringMap.keySet().iterator();
            while (iterator.hasNext()) {
                String key = iterator.next();
                Integer[] parts = MergeUtil.getParts(key);
                if (parts != null && parts.length > 1) {
                    Integer fieldOrIndex = parts[0];
                    Integer parametertCode = parts[1];
                    if (fieldOrIndex != null && fieldOrIndex.equals(fieldID) && parametertCode != null) {
                        String partStringValue = displayStringMap.get(key);
                        if (partStringValue != null) {
                            try {
                                actualValuesMap.put(parametertCode,
                                        new Integer[] { Integer.valueOf(partStringValue) });
                            } catch (Exception e) {
                                LOGGER.warn("Converting the " + partStringValue
                                        + " to Integer from display string failed with " + e.getMessage());
                                LOGGER.debug(ExceptionUtils.getStackTrace(e));
                            }
                        }
                    }
                }
            }
            return actualValuesMap;
        }
    }
    return null;
}

From source file:com.sshtools.appframework.api.ui.ToolsBuilder.java

protected void rebuildContainer(Collection<AppAction> enabledActions) {

    container.invalidate();//  ww  w . java 2s . c  o  m
    container.removeAll();

    boolean useSmallIcons = PreferencesStore.getBoolean(SshToolsApplication.PREF_TOOLBAR_SMALL_ICONS, false);
    boolean showSelectiveText = PreferencesStore
            .getBoolean(SshToolsApplication.PREF_TOOLBAR_SHOW_SELECTIVE_TEXT, true);

    // Build the tool bar action list, grouping the actions
    List<AppAction> toolBarActions = new ArrayList<AppAction>();
    for (AppAction action : enabledActions) {
        if (Boolean.TRUE.equals(action.getValue(AppAction.ON_TOOLBAR))) {
            toolBarActions.add(action);
        }
    }
    log.debug("There are " + toolBarActions.size() + " in the toolbar");
    Collections.sort(toolBarActions, new ToolBarActionComparator());

    // Build the tool bar
    Integer grp = null;
    for (AppAction z : toolBarActions) {
        boolean grow = Boolean.TRUE.equals(z.getValue(AppAction.GROW));
        String constraints = grow ? "grow" : null;
        if ((grp != null) && !grp.equals(z.getValue(AppAction.TOOLBAR_GROUP))) {
            container.add(new ToolBarSeparator(), null);
        }
        if (z.getValue(AppAction.COMPONENT) != null) {
            JComponent jc = (JComponent) z.getValue(AppAction.COMPONENT);
            container.add(jc, constraints);
        } else if (Boolean.TRUE.equals(z.getValue(AppAction.IS_TOGGLE_BUTTON))) {
            ActionToggleButton tBtn = new ActionToggleButton(z, !useSmallIcons, showSelectiveText);
            container.add(tBtn, constraints);
        } else {
            ActionButton btn = new ActionButton(z,
                    !useSmallIcons ? AppAction.MEDIUM_ICON : AppAction.SMALL_ICON, showSelectiveText);
            container.add(btn, constraints);
        }
        grp = (Integer) z.getValue(AppAction.TOOLBAR_GROUP);
    }
    container.validate();
    container.repaint();
    if (container.getParent() != null) {
        container.getParent().validate();
    }
}

From source file:com.vmware.o11n.plugin.crypto.service.CryptoCertificateService.java

/**
 *
 * @param cert/*from   ww  w.  ja v  a 2  s .c om*/
 * @return
 * @throws CertificateParsingException
 */

public List<String> getSubjectAlternativeNames(X509Certificate cert) throws CertificateParsingException {
    ArrayList<String> toReturn = new ArrayList<>();
    Collection<List<?>> sans = cert.getSubjectAlternativeNames();
    if (sans != null) {
        if (log.isDebugEnabled()) {
            log.debug("Subject Alternative Names: " + sans.toString());
        }
        for (List<?> l : sans) {
            if (l.size() == 2) {
                Integer type = (Integer) l.get(0);
                if (type.equals(new Integer(2))) {
                    //DNS SAN
                    String value = (String) l.get(1);
                    toReturn.add("dns:" + value);
                } else {
                    String message = "SAN type '" + sanType.get(type) + "' not implemented";
                    log.warn(message);
                }
            } else {
                log.error("expected subject alternatives names object to have only 2 elements but " + l.size()
                        + " elements were present");
            }
        }
    } else if (log.isDebugEnabled()) {
        log.debug("Empty Subject Alternative Names");
    }
    return toReturn;
}

From source file:io.fluo.stress.TrieBasicIT.java

private void runTrieTest(int ingestNum, int maxValue, int nodeSize) throws Exception {

    log.info("Ingesting " + ingestNum + " unique numbers with a nodeSize of " + nodeSize + " bits");

    config.setLoaderThreads(0);//from  w w w.j a  v  a2  s  .com
    config.setLoaderQueueSize(0);

    try (Environment env = new Environment(config);
            LoaderExecutorImpl le = new LoaderExecutorImpl(config, env)) {
        Random random = new Random();
        Set<Integer> ingested = new HashSet<>();
        for (int i = 0; i < ingestNum; i++) {
            int num = Math.abs(random.nextInt(maxValue));
            le.execute(new NumberLoader(num, nodeSize));
            ingested.add(num);
        }
        int uniqueNum = ingested.size();

        log.info("Ingested " + uniqueNum + " unique numbers with a nodeSize of " + nodeSize + " bits");

        miniFluo.waitForObservers();

        try (TypedSnapshot tsnap = TYPEL.wrap(client.newSnapshot())) {
            Integer result = tsnap.get().row(Node.generateRootId(nodeSize)).col(COUNT_SEEN_COL).toInteger();
            if (result == null) {
                log.error("Could not find root node");
                printSnapshot();
            }
            if (!result.equals(uniqueNum)) {
                log.error("Count (" + result + ") at root node does not match expected (" + uniqueNum + "):");
                printSnapshot();
            }
            Assert.assertEquals(uniqueNum, result.intValue());
        }
    }
}

From source file:org.myjerry.evenstar.service.impl.ViewPostServiceImpl.java

public List<CommentInfo> getCommentList(Collection<Comment> comments, Long blogID, EvenstarUser user,
        String commentTimeStampFormat) {
    List<CommentInfo> list = new ArrayList<CommentInfo>();

    if (StringUtils.isEmpty(commentTimeStampFormat)) {
        commentTimeStampFormat = "EEEE, MMMM d, yyyy";
    }//  ww w. ja  v a 2 s .  com

    // check if the current user has permission to view the comment
    boolean allowed = this.blogUserService.isUserBlogAdmin(user.getUserID(), blogID);

    if (comments != null) {
        for (Comment comment : comments) {
            CommentInfo commentInfo = new CommentInfo(comment, commentTimeStampFormat);
            Integer permissions = comment.getPermissions();
            if (permissions != null && permissions.equals(Comment.PRIVACY_MODE_PRIVATE)) {
                if (!allowed) {
                    commentInfo.setBody("The comment author has restricted access to the blog authors.");
                    commentInfo.setRestricted(allowed);
                }
            }
            list.add(commentInfo);
        }
    }
    return list;
}

From source file:bql.util.JsonComparator.java

private boolean isEqualsInteger(Integer a, Integer b) {
    if (a == null ^ b == null) {
        return false;
    } else if (a == null && b == null) {
        return true;
    }/*ww w  .ja  va  2  s .c  o m*/
    return a.equals(b);
}

From source file:org.springbyexample.orm.hibernate3.annotation.dao.PersonAnnotationDaoTest.java

@Test
public void testHibernateTemplate() throws SQLException {
    assertNotNull("Person DAO is null.", personDao);

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

    int expected = 2;

    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());
            }/*w ww. ja v  a 2s.  c o m*/
        }

        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());
    }
}