Example usage for java.lang Long equals

List of usage examples for java.lang Long equals

Introduction

In this page you can find the example usage for java.lang Long equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Compares this object to the specified object.

Usage

From source file:de.micromata.genome.chronos.spi.ram.RamJobStore.java

@Override
public synchronized List<TriggerJobDisplayDO> getAdminJobs(String hostName, String name, String state,
        String schedulerName, int resultCount, boolean withLastResult) {
    Long schedulerPk = null;
    if (StringUtils.isNotEmpty(schedulerName) == true) {
        SchedulerDO sched = schedulersByName.get(schedulerName);
        if (sched != null) {
            schedulerPk = sched.getPk();
        }/*  w w w  .  ja va  2s  .c om*/
    }
    List<TriggerJobDisplayDO> ret = new ArrayList<TriggerJobDisplayDO>();
    for (Map.Entry<Long, Map<Long, TriggerJobDO>> m : allJobs.entrySet()) {
        if (schedulerPk != null && schedulerPk.equals(m.getKey()) == false) {
            continue;
        }
        for (Map.Entry<Long, TriggerJobDO> e : m.getValue().entrySet()) {
            if (StringUtils.isNotEmpty(hostName)
                    && StringUtils.equals(hostName, e.getValue().getHostName()) == false) {
                continue;
            }
            if (StringUtils.isNotEmpty(state)
                    && StringUtils.equals(state, e.getValue().getState().name()) == false) {
                continue;
            }
            TriggerJobDisplayDO tjd = new TriggerJobDisplayDO(e.getValue());
            ret.add(tjd);
        }

    }
    return ret;
}

From source file:sx.blah.discord.DiscordClient.java

/**
  * Attempts to get the name of the game based on its id
  * /*from   w w  w.  j  a va 2s . c o  m*/
  * @param gameId The game id (nullable!)
  * @return The game name, the Optional will be empty if the game couldn't be found
  */
public Optional<String> getGameByID(Long gameId) {
    if (games == null || gameId == null)
        return Optional.empty();

    for (Object object : games) {
        if (!(object instanceof JSONObject))
            continue;

        JSONObject jsonObject = (JSONObject) object;
        Long id = (Long) jsonObject.get("id");
        if (id != null) {
            if (id.equals(gameId))
                return Optional.ofNullable((String) jsonObject.get("name"));
        }
    }

    return Optional.empty();
}

From source file:org.apache.hadoop.hive.metastore.MetaStoreUtils.java

static boolean isFastStatsSame(Partition oldPart, Partition newPart) {
    // requires to calculate stats if new and old have different fast stats
    if ((oldPart != null) && (oldPart.getParameters() != null)) {
        for (String stat : StatsSetupConst.fastStats) {
            if (oldPart.getParameters().containsKey(stat)) {
                Long oldStat = Long.parseLong(oldPart.getParameters().get(stat));
                Long newStat = Long.parseLong(newPart.getParameters().get(stat));
                if (!oldStat.equals(newStat)) {
                    return false;
                }/*w w w  . j av  a 2s  .  c o m*/
            } else {
                return false;
            }
        }
        return true;
    }
    return false;
}

From source file:jp.primecloud.auto.ui.WinServerAdd.java

private void showImages(Long platformNo) {
    imageTable.removeAllItems();/* w  w  w.  j  a  v  a  2 s  .  c  o  m*/
    serviceTable.removeAllItems();
    if (platformNo == null) {
        return;
    }

    // ????????
    List<ImageDto> images = null;
    for (PlatformDto platform : platforms) {
        if (platformNo.equals(platform.getPlatform().getPlatformNo())) {
            images = platform.getImages();
            break;
        }
    }

    // ?????
    if (images == null) {
        return;
    }

    // ??
    int n = 0;
    for (ImageDto image : images) {
        // ?????????
        if (BooleanUtils.isNotTrue(image.getImage().getSelectable())) {
            continue;
        }

        // ???
        String name = image.getImage().getImageNameDisp();
        Icons nameIcon = CommonUtils.getImageIcon(image);

        Label nlbl = new Label(
                "<img src=\"" + VaadinUtils.getIconPath(apl, nameIcon) + "\"><div>" + name + "</div>",
                Label.CONTENT_XHTML);
        nlbl.setHeight(COLUMN_HEIGHT);

        // OS??
        String os = image.getImage().getOsDisp();
        Icons osIcon = CommonUtils.getOsIcon(image);

        Label slbl = new Label(
                "<img src=\"" + VaadinUtils.getIconPath(apl, osIcon) + "\"><div>" + os + "</div>",
                Label.CONTENT_XHTML);
        slbl.setHeight(COLUMN_HEIGHT);

        n++;
        imageTable.addItem(new Object[] { n, nlbl, slbl }, image.getImage().getImageNo());
    }

    Long imageNo = null;
    if (imageTable.getItemIds().size() > 0) {
        imageNo = (Long) imageTable.getItemIds().toArray()[0];
    }

    // ????
    imageTable.select(imageNo);
}

From source file:jp.primecloud.auto.ui.WinServerAddSimple.java

private void addButtonClick(List<String> serverNames) {

    // ?/* w w  w .j  a  va  2 s  . com*/
    Long platformNo = (Long) cloudTable.getValue();
    Long farmNo = ViewContext.getFarmNo();

    // TODO: ?
    String comment = "";
    InstanceService instanceService = BeanContext.getBean(InstanceService.class);

    // ??
    PlatformDto platformDto = null;
    ImageDto imageDto = null;
    for (PlatformDto platform : platforms) {
        if (platformNo.equals(platform.getPlatform().getPlatformNo())) {
            platformDto = platform;
            for (ImageDto tmpImage : platform.getImages()) {
                // ????????
                if (!tmpImage.getImage().getSelectable()) {
                    continue;
                }
                for (ComponentType tmpComponentType : tmpImage.getComponentTypes()) {
                    if (componentTypeNo.equals(tmpComponentType.getComponentTypeNo())) {
                        imageDto = tmpImage;
                        break;
                    }
                }
                if (imageDto != null) {
                    break;
                }
            }
            break;
        }
    }

    for (String serverName : serverNames) {
        // 
        // TODO CLOUD BRANCHING
        if (PCCConstant.PLATFORM_TYPE_AWS.equals(platformDto.getPlatform().getPlatformType())) {
            // AWS??
            try {
                String[] instanceTypes = imageDto.getImageAws().getInstanceTypes().split(",");
                instanceService.createIaasInstance(farmNo, serverName, platformNo, comment,
                        imageDto.getImage().getImageNo(), instanceTypes[0].trim());
            } catch (AutoApplicationException e) {
                String message = ViewMessages.getMessage(e.getCode(), e.getAdditions());
                DialogConfirm dialog = new DialogConfirm(ViewProperties.getCaption("dialog.error"), message);
                getApplication().getMainWindow().addWindow(dialog);
                return;
            }
        } else if (PCCConstant.PLATFORM_TYPE_VMWARE.equals(platformDto.getPlatform().getPlatformType())) {
            // VMware??
            try {
                String[] instanceTypes = imageDto.getImageVmware().getInstanceTypes().split(",");
                instanceService.createVmwareInstance(farmNo, serverName, platformNo, comment,
                        imageDto.getImage().getImageNo(), instanceTypes[0].trim());
            } catch (AutoApplicationException e) {
                String message = ViewMessages.getMessage(e.getCode(), e.getAdditions());
                DialogConfirm dialog = new DialogConfirm(ViewProperties.getCaption("dialog.error"), message);
                getApplication().getMainWindow().addWindow(dialog);
                return;
            }
        } else if (PCCConstant.PLATFORM_TYPE_NIFTY.equals(platformDto.getPlatform().getPlatformType())) {
            // Nifty??
            try {
                String[] instanceTypes = imageDto.getImageNifty().getInstanceTypes().split(",");
                instanceService.createNiftyInstance(farmNo, serverName, platformNo, comment,
                        imageDto.getImage().getImageNo(), instanceTypes[0].trim());
            } catch (AutoApplicationException e) {
                String message = ViewMessages.getMessage(e.getCode(), e.getAdditions());
                DialogConfirm dialog = new DialogConfirm(ViewProperties.getCaption("dialog.error"), message);
                getApplication().getMainWindow().addWindow(dialog);
                return;
            }
        } else if (PCCConstant.PLATFORM_TYPE_CLOUDSTACK.equals(platformDto.getPlatform().getPlatformType())) {
            // CloudStack??
            try {
                String[] instanceTypes = imageDto.getImageCloudstack().getInstanceTypes().split(",");
                instanceService.createIaasInstance(farmNo, serverName, platformNo, comment,
                        imageDto.getImage().getImageNo(), instanceTypes[0].trim());
            } catch (AutoApplicationException e) {
                String message = ViewMessages.getMessage(e.getCode(), e.getAdditions());
                DialogConfirm dialog = new DialogConfirm(ViewProperties.getCaption("dialog.error"), message);
                getApplication().getMainWindow().addWindow(dialog);
                return;
            }
        } else if (PCCConstant.PLATFORM_TYPE_VCLOUD.equals(platformDto.getPlatform().getPlatformType())) {
            // VCloud??
            try {
                String[] instanceTypes = imageDto.getImageVcloud().getInstanceTypes().split(",");
                instanceService.createIaasInstance(farmNo, serverName, platformNo, comment,
                        imageDto.getImage().getImageNo(), instanceTypes[0].trim());
            } catch (AutoApplicationException e) {
                String message = ViewMessages.getMessage(e.getCode(), e.getAdditions());
                DialogConfirm dialog = new DialogConfirm(ViewProperties.getCaption("dialog.error"), message);
                getApplication().getMainWindow().addWindow(dialog);
                return;
            }
        } else if (PCCConstant.PLATFORM_TYPE_AZURE.equals(platformDto.getPlatform().getPlatformType())) {
            // Azure??
            try {
                String[] instanceTypes = imageDto.getImageAzure().getInstanceTypes().split(",");
                instanceService.createIaasInstance(farmNo, serverName, platformNo, comment,
                        imageDto.getImage().getImageNo(), instanceTypes[0].trim());
            } catch (AutoApplicationException e) {
                String message = ViewMessages.getMessage(e.getCode(), e.getAdditions());
                DialogConfirm dialog = new DialogConfirm(ViewProperties.getCaption("dialog.error"), message);
                getApplication().getMainWindow().addWindow(dialog);
                return;
            }
        } else if (PCCConstant.PLATFORM_TYPE_OPENSTACK.equals(platformDto.getPlatform().getPlatformType())) {
            // OpenStack??
            try {
                String[] instanceTypes = imageDto.getImageOpenstack().getInstanceTypes().split(",");
                instanceService.createIaasInstance(farmNo, serverName, platformNo, comment,
                        imageDto.getImage().getImageNo(), instanceTypes[0].trim());
            } catch (AutoApplicationException e) {
                String message = ViewMessages.getMessage(e.getCode(), e.getAdditions());
                DialogConfirm dialog = new DialogConfirm(ViewProperties.getCaption("dialog.error"), message);
                getApplication().getMainWindow().addWindow(dialog);
                return;
            }
        }
    }

    //
    AutoApplication aapl = (AutoApplication) apl;
    String prefix = (String) prefixField.getValue();
    String serverNumber = String.valueOf(this.serverNumber.getValue());
    aapl.doOpLog("SIMPLE_SERVER", "Make Server Simple", null, null, null, prefix + ":" + serverNumber);

    // ????????
    ContextUtils.setAttribute("serverNames", serverNames);

    // ??
    close();

}

From source file:com.sawyer.advadapters.widget.JSONAdapter.java

/**
 * Determines whether the provided constraint filters out the given item. Subclass to provide
 * you're own logic. It's incorrect to modify the adapter or the contents of the item itself.
 * Any alterations will lead to undefined behavior or crashes. Internally, this method is only
 * ever invoked from a background thread.
 *
 * @param item       The Long item to compare against the constraint
 * @param constraint The constraint used to filter the item
 *
 * @return True if the item is filtered out by the given constraint. False if the item will
 * continue to display in the adapter.//from  w w w.  j a  v a  2 s .c o  m
 */
protected boolean isFilteredOut(Long item, CharSequence constraint) {
    try {
        return !item.equals(Long.valueOf(constraint.toString()));
    } catch (NumberFormatException e) {
        return true;
    }
}

From source file:biz.wolschon.fileformats.gnucash.baseclasses.SimpleAccount.java

/**
 * Compares our name to o.toString() .<br/>
 * If both starts with some digits the resulting
 * ${@link java.lang.Integer} are compared.<br/>
 * If one starts with a number and the other does not,
 * the one starting with a number is "bigger"<br/>
 * else and if both integers are equals a normals comparison of the
 * {@link java.lang.String} is done.     *
 * @param   o the Object to be compared.
 * @return  a negative integer, zero, or a positive integer as this object
 *      is less than, equal to, or greater than the specified object.
 *
 * @throws ClassCastException if the specified object's type prevents it
 *         from being compared to this Object.
 *///  ww w  .  jav  a2  s.  com
public int compareNamesTo(final Object o) throws ClassCastException {

    // usually compare the qualified name
    String other = o.toString();
    String me = getQualifiedName();

    // if we have the same parent,
    // compare the unqualified name.
    // This enshures that the exception
    // for numbers is used within our parent-
    // account too and not just in the top-
    // level accounts
    if (o instanceof GnucashAccount && ((GnucashAccount) o).getParentAccountId() != null
            && getParentAccountId() != null
            && ((GnucashAccount) o).getParentAccountId().equalsIgnoreCase(getParentAccountId())) {
        other = ((GnucashAccount) o).getName();
        me = getName();
    }

    // compare

    Long i0 = startsWithNumber(other);
    Long i1 = startsWithNumber(me);
    if (i0 == null && i1 != null) {
        return 1;
    }
    if (i1 == null && i0 != null) {
        return -1;
    }
    if (i0 == null) {
        return me.compareTo(other);
    }
    if (i1 == null) {
        return me.compareTo(other);
    }

    if (i1.equals(i0)) {
        return me.compareTo(other);
    }

    return i1.compareTo(i0);
}

From source file:ome.security.basic.OmeroInterceptor.java

/**
 * Checks the details of the objects which the given object links to in
 * order to guarantee that linkages are valid.
 *
 * This method is called during/* w  w w .  j a v  a2 s.co m*/
 * {@link OmeroInterceptor#onSave(Object, java.io.Serializable, Object[], String[], org.hibernate.type.Type[])
 * save} and
 * {@link OmeroInterceptor#onFlushDirty(Object, java.io.Serializable, Object[], Object[], String[], org.hibernate.type.Type[])
 * update} since this is the only time that new entity references can be
 * created.
 *
 * @param iObject
 *            new or updated entity which may reference other entities which
 *            then require locking. Nulls are tolerated but do nothing.
 * @param ownerId
 *            the id of the current owner. May be null in which case, the
 *            current owner id will most likely be replaced. (If not, then
 *            a security exception will be raised later)
 */
public void evaluateLinkages(IObject iObject) {

    if (iObject == null || sysTypes.isSystemType(iObject.getClass())
            || sysTypes.isInSystemGroup(iObject.getDetails())) {
        return;
    }

    IObject[] candidates = em.getLockCandidates(iObject);
    for (IObject object : candidates) {

        if (!sysTypes.isSystemType(object.getClass()) && !sysTypes.isInSystemGroup(object.getDetails())
                && !sysTypes.isInUserGroup(object.getDetails())) {

            Details d = object.getDetails();
            if (d == null) {
                // ticket:2575. Previously, the details of the candidates
                // were never null. the addition of the reagent linkages
                // *somehow* led to NPEs here. for the moment, we're assuming
                // if null, then the object can't be mis-linked. (i.e. it's
                // probably new)
                continue;
            }

            if (d != null && d.getGroup() != null
                    && !HibernateUtils.idEqual(d.getGroup(), currentUser.getGroup())) {
                throw new GroupSecurityViolation(
                        String.format("MIXED GROUP: " + "%s(group=%s) and %s(group=%s) cannot be linked.",
                                iObject, currentUser.getGroup(), object, d.getGroup()));
            }

            // Rather than as in <=4.1 in which objects were scheduled
            // for locking which prevented later actions, now we check
            // whether or not we're graph critical and if so, and if
            // the objects do not belong the current user, then we abort.

            Experimenter owner = object.getDetails().getOwner();
            if (owner == null) {
                continue;
            }
            Long oid = owner.getId();
            Long uid = currentUser.getOwner().getId();
            if (oid != null && !uid.equals(oid)) {
                if (currentUser.isGraphCritical()) { // ticket:1769
                    String gname = currentUser.getGroup().getName();
                    String oname = currentUser.getOwner().getOmeName();
                    Permissions p = currentUser.getCurrentEventContext().getCurrentGroupPermissions();
                    throw new ReadOnlyGroupSecurityViolation(String.format("Cannot link to %s\n"
                            + "Current user (%s) is an admin or the owner of\n"
                            + "the private group (%s=%s). It is not allowed to\n" + "link to users' data.",
                            object, oname, gname, p));
                } else if (!currentUser.getCurrentEventContext().getCurrentGroupPermissions()
                        .isGranted(Role.GROUP, Right.WRITE)) {// ticket:1992
                    throw new ReadOnlyGroupSecurityViolation(
                            "Group is READ-ONLY. " + "Cannot link to object: " + object);
                }
            }
        }
    }

}

From source file:com.gsma.rcs.ri.messaging.OneToOneTalkView.java

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.menu_1to1_talk_item, menu);
    menu.findItem(R.id.menu_resend_message).setVisible(false);
    menu.findItem(R.id.menu_display_content).setVisible(false);
    menu.findItem(R.id.menu_listen_content).setVisible(false);
    /* Get the list item position */
    AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo;
    Cursor cursor = (Cursor) mAdapter.getItem(info.position);
    /* Adapt the contextual menu according to the selected item */
    int providerId = cursor.getInt(cursor.getColumnIndexOrThrow(HistoryLog.PROVIDER_ID));
    String id = cursor.getString(cursor.getColumnIndexOrThrow(HistoryLog.ID));
    Direction direction = Direction.valueOf(cursor.getInt(cursor.getColumnIndexOrThrow(HistoryLog.DIRECTION)));
    try {/*from   w  w  w . jav  a2  s.  c o m*/
        switch (providerId) {
        case ChatLog.Message.HISTORYLOG_MEMBER_ID:
            if (Direction.OUTGOING == direction) {
                ChatLog.Message.Content.Status status = ChatLog.Message.Content.Status
                        .valueOf(cursor.getInt(cursor.getColumnIndexOrThrow(HistoryLog.STATUS)));
                if (ChatLog.Message.Content.Status.FAILED == status) {
                    String number = cursor.getString(cursor.getColumnIndexOrThrow(HistoryLog.CONTACT));
                    if (number != null) {
                        ContactId contact = ContactUtil.formatContact(number);
                        OneToOneChat chat = mChatService.getOneToOneChat(contact);
                        if (chat != null && chat.isAllowedToSendMessage()) {
                            menu.findItem(R.id.menu_resend_message).setVisible(true);
                        }
                    }
                }
            }
            break;

        case FileTransferLog.HISTORYLOG_MEMBER_ID:
            String mimeType = cursor.getString(cursor.getColumnIndexOrThrow(HistoryLog.MIME_TYPE));
            FileTransfer.State state = FileTransfer.State
                    .valueOf(cursor.getInt(cursor.getColumnIndexOrThrow(HistoryLog.STATUS)));
            if (FileTransfer.State.FAILED == state) {
                FileTransfer transfer = mFileTransferService.getFileTransfer(id);
                if (transfer != null && transfer.isAllowedToResendTransfer()) {
                    menu.findItem(R.id.menu_resend_message).setVisible(true);
                }
            } else if (Utils.isImageType(mimeType)) {
                if (Direction.OUTGOING == direction) {
                    menu.findItem(R.id.menu_display_content).setVisible(true);

                } else if (Direction.INCOMING == direction) {
                    Long transferred = cursor.getLong(cursor.getColumnIndexOrThrow(HistoryLog.TRANSFERRED));
                    Long size = cursor.getLong(cursor.getColumnIndexOrThrow(HistoryLog.FILESIZE));
                    if (size.equals(transferred)) {
                        menu.findItem(R.id.menu_display_content).setVisible(true);
                    }
                }
            } else if (Utils.isAudioType(mimeType)) {
                if (Direction.OUTGOING == direction) {
                    menu.findItem(R.id.menu_listen_content).setVisible(true);

                } else if (Direction.INCOMING == direction) {
                    Long transferred = cursor.getLong(cursor.getColumnIndexOrThrow(HistoryLog.TRANSFERRED));
                    Long size = cursor.getLong(cursor.getColumnIndexOrThrow(HistoryLog.FILESIZE));
                    if (size.equals(transferred)) {
                        menu.findItem(R.id.menu_listen_content).setVisible(true);
                    }
                }
            }
            break;

        default:
            throw new IllegalArgumentException("Invalid provider ID=" + providerId);
        }
    } catch (RcsServiceNotAvailableException e) {
        menu.findItem(R.id.menu_resend_message).setVisible(false);

    } catch (RcsGenericException | RcsPersistentStorageException e) {
        menu.findItem(R.id.menu_resend_message).setVisible(false);
        showException(e);
    }
}

From source file:com.selfsoft.business.service.impl.StatisticsStockInOutServiceImpl.java

/**
 * ?????? -- ???//from  w w  w. j  a  v a  2 s  . com
 * @Date      2010-7-9
 * @Function  
 * @param partInfoId
 * @param elementType
 * @return
 */
public List<TbPartInfoReFlowStatVo> getPartInfoReFlowDetailStat(List<TbPartInfo> tbPartInfoList,
        Long elementType, TbPartInfoReFlowStatVo tbPartInfoReFlowStatVo) {
    List<TbPartInfoReFlowStatVo> results = new ArrayList<TbPartInfoReFlowStatVo>();

    List<Object[]> list = null;

    if (null != tbPartInfoList) {
        String[] partIds = new String[tbPartInfoList.size()];
        for (int i = 0; i < tbPartInfoList.size(); i++) {
            partIds[i] = tbPartInfoList.get(i).getId() + "";
        }
        list = tbPartInfoDao.getPartInfoReFlowDetailStat(StringUtils.join(partIds, ","), elementType,
                tbPartInfoReFlowStatVo);
    } else {
        list = tbPartInfoDao.getPartInfoReFlowDetailStat(null, elementType, tbPartInfoReFlowStatVo);

    }

    for (Object[] obj : list) {

        TbPartInfoReFlowStatVo vo = new TbPartInfoReFlowStatVo();
        String dateStr = obj[0] != null ? obj[0].toString() : null;
        Date date = CommonMethod.parseStringToDate(dateStr, "yyyy-MM-dd");
        vo.setCreateDate(date);
        vo.setElementType(
                obj[1] != null ? StockTypeElements.getElementMap().get(new Long(obj[1].toString())) : null);
        Double partQuantity = obj[2] != null ? Double.valueOf(obj[2].toString()) : null;
        Long typeVal = StockTypeElements.getElementTypeVal(Long.valueOf(obj[1].toString()));
        if (typeVal.equals(1L)) {
            //
            vo.setInQuantity(partQuantity);
        }
        if (typeVal.equals(2L)) {
            //
            vo.setOutQuantity(partQuantity);
        }

        vo.setRatePrice(obj[3] != null ? Double.valueOf(obj[3].toString()) : null);
        vo.setSubTotalPrice(obj[4] != null ? Double.valueOf(obj[4].toString()) : null);
        vo.setCustomerName(obj[5] != null ? obj[5].toString() : null);
        Long tbCarInfoId = obj[7] != null ? Long.valueOf(obj[7].toString()) : null;
        vo.setTbCarInfoId(tbCarInfoId);
        vo.setLicenseCode(obj[8] != null ? obj[8].toString() : null);
        vo.setChassisCode(obj[9] != null ? obj[9].toString() : null);
        results.add(vo);
    }

    return results;
}