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.tasktop.c2c.server.internal.wiki.server.WikiServiceController.java

@Section("Attachments")
@Title("Create Page Attachment")
@Documentation("Create a page attachment. The provided attachment must have a name, mime type and content.")
@RequestMapping(value = "/page/{pageId}/attachment", method = RequestMethod.POST)
public AttachmentHandle createAttachment(@PathVariable(value = "pageId") Integer pageId,
        @RequestBody Attachment attachment) throws EntityNotFoundException, ValidationException {
    if (pageId == null || attachment.getPage() == null || !pageId.equals(attachment.getPage().getId())) {
        throw new EntityNotFoundException();
    }/*ww  w .  j  a  v a 2s.  co  m*/
    return createAttachment(attachment);
}

From source file:io.github.swagger2markup.internal.component.PropertiesTableComponent.java

public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, Parameters params) {
    //TODO: This method is too complex, split it up in smaller methods to increase readability
    StringColumn.Builder nameColumnBuilder = StringColumn
            .builder(ColumnIds.StringColumnId.of(labels.getLabel(NAME_COLUMN)))
            .putMetaData(TableComponent.WIDTH_RATIO, "3");

    StringColumn.Builder descriptionColumnBuilder = StringColumn
            .builder(ColumnIds.StringColumnId.of(labels.getLabel(DESCRIPTION_COLUMN)))
            .putMetaData(TableComponent.WIDTH_RATIO, "11").putMetaData(TableComponent.HEADER_COLUMN, "true");

    StringColumn.Builder schemaColumnBuilder = StringColumn
            .builder(ColumnIds.StringColumnId.of(labels.getLabel(SCHEMA_COLUMN)))
            .putMetaData(TableComponent.WIDTH_RATIO, "4").putMetaData(TableComponent.HEADER_COLUMN, "true");

    Map<String, Property> properties = params.properties;
    if (MapUtils.isNotEmpty(properties)) {
        Map<String, Property> sortedProperties = toSortedMap(properties, config.getPropertyOrdering());
        sortedProperties.forEach((String propertyName, Property property) -> {
            PropertyAdapter propertyAdapter = new PropertyAdapter(property);
            Type propertyType = propertyAdapter.getType(definitionDocumentResolver);

            if (config.isInlineSchemaEnabled()) {
                propertyType = createInlineType(propertyType, propertyName,
                        params.parameterName + " " + propertyName, params.inlineDefinitions);
            }//w w  w. j a  va 2s .  c om

            Optional<Object> optionalExample = propertyAdapter.getExample(config.isGeneratedExamplesEnabled(),
                    markupDocBuilder);
            Optional<Object> optionalDefaultValue = propertyAdapter.getDefaultValue();
            Optional<Integer> optionalMaxLength = propertyAdapter.getMaxlength();
            Optional<Integer> optionalMinLength = propertyAdapter.getMinlength();
            Optional<String> optionalPattern = propertyAdapter.getPattern();
            Optional<Number> optionalMinValue = propertyAdapter.getMin();
            boolean exclusiveMin = propertyAdapter.getExclusiveMin();
            Optional<Number> optionalMaxValue = propertyAdapter.getMax();
            boolean exclusiveMax = propertyAdapter.getExclusiveMax();

            MarkupDocBuilder propertyNameContent = copyMarkupDocBuilder(markupDocBuilder);
            propertyNameContent.boldTextLine(propertyName, true);
            if (property.getRequired())
                propertyNameContent.italicText(labels.getLabel(FLAGS_REQUIRED).toLowerCase());
            else
                propertyNameContent.italicText(labels.getLabel(FLAGS_OPTIONAL).toLowerCase());
            if (propertyAdapter.getReadOnly()) {
                propertyNameContent.newLine(true);
                propertyNameContent.italicText(labels.getLabel(FLAGS_READ_ONLY).toLowerCase());
            }

            MarkupDocBuilder descriptionContent = copyMarkupDocBuilder(markupDocBuilder);
            String description = markupDescription(config.getSwaggerMarkupLanguage(), markupDocBuilder,
                    property.getDescription());
            if (isNotBlank(description))
                descriptionContent.text(description);

            if (optionalDefaultValue.isPresent()) {
                if (isNotBlank(descriptionContent.toString())) {
                    descriptionContent.newLine(true);
                }
                descriptionContent.boldText(labels.getLabel(DEFAULT_COLUMN)).text(COLON)
                        .literalText(Json.pretty(optionalDefaultValue.get()));
            }

            if (optionalMinLength.isPresent() && optionalMaxLength.isPresent()) {
                // combination of minlength/maxlength
                Integer minLength = optionalMinLength.get();
                Integer maxLength = optionalMaxLength.get();

                if (isNotBlank(descriptionContent.toString())) {
                    descriptionContent.newLine(true);
                }

                String lengthRange = minLength + " - " + maxLength;
                if (minLength.equals(maxLength)) {
                    lengthRange = minLength.toString();
                }

                descriptionContent.boldText(labels.getLabel(LENGTH_COLUMN)).text(COLON)
                        .literalText(lengthRange);

            } else {
                if (optionalMinLength.isPresent()) {
                    if (isNotBlank(descriptionContent.toString())) {
                        descriptionContent.newLine(true);
                    }
                    descriptionContent.boldText(labels.getLabel(MINLENGTH_COLUMN)).text(COLON)
                            .literalText(optionalMinLength.get().toString());
                }

                if (optionalMaxLength.isPresent()) {
                    if (isNotBlank(descriptionContent.toString())) {
                        descriptionContent.newLine(true);
                    }
                    descriptionContent.boldText(labels.getLabel(MAXLENGTH_COLUMN)).text(COLON)
                            .literalText(optionalMaxLength.get().toString());
                }
            }

            if (optionalPattern.isPresent()) {
                if (isNotBlank(descriptionContent.toString())) {
                    descriptionContent.newLine(true);
                }
                descriptionContent.boldText(labels.getLabel(PATTERN_COLUMN)).text(COLON)
                        .literalText(Json.pretty(optionalPattern.get()));
            }

            if (optionalMinValue.isPresent()) {
                if (isNotBlank(descriptionContent.toString())) {
                    descriptionContent.newLine(true);
                }
                String minValueColumn = exclusiveMin ? labels.getLabel(MINVALUE_EXCLUSIVE_COLUMN)
                        : labels.getLabel(MINVALUE_COLUMN);
                descriptionContent.boldText(minValueColumn).text(COLON)
                        .literalText(optionalMinValue.get().toString());
            }

            if (optionalMaxValue.isPresent()) {
                if (isNotBlank(descriptionContent.toString())) {
                    descriptionContent.newLine(true);
                }
                String maxValueColumn = exclusiveMax ? labels.getLabel(MAXVALUE_EXCLUSIVE_COLUMN)
                        : labels.getLabel(MAXVALUE_COLUMN);
                descriptionContent.boldText(maxValueColumn).text(COLON)
                        .literalText(optionalMaxValue.get().toString());
            }

            if (optionalExample.isPresent()) {
                if (isNotBlank(description) || optionalDefaultValue.isPresent()) {
                    descriptionContent.newLine(true);
                }
                descriptionContent.boldText(labels.getLabel(EXAMPLE_COLUMN)).text(COLON)
                        .literalText(Json.pretty(optionalExample.get()));
            }

            nameColumnBuilder.add(propertyNameContent.toString());
            descriptionColumnBuilder.add(descriptionContent.toString());
            schemaColumnBuilder.add(propertyType.displaySchema(markupDocBuilder));
        });
    }

    return tableComponent.apply(markupDocBuilder, TableComponent.parameters(nameColumnBuilder.build(),
            descriptionColumnBuilder.build(), schemaColumnBuilder.build()));
}

From source file:com.alibaba.doris.admin.service.common.route.RouteConfigProcessor.java

private void validateNodes(Collection<PhysicalNodeDO> allPhyNodes) throws DorisConfigServiceException {

    //for validate logical id
    Map<StoreNodeSequenceEnum, List<PhysicalNodeDO>> nodesGroup = new HashMap<StoreNodeSequenceEnum, List<PhysicalNodeDO>>();
    // for validate nodes.
    Map<String, Set<StoreNodeSequenceEnum>> ipGroups = new HashMap<String, Set<StoreNodeSequenceEnum>>();
    for (PhysicalNodeDO node : allPhyNodes) {
        StoreNodeSequenceEnum seq = StoreNodeSequenceEnum.getTypeByValue(node.getSerialId());
        if (seq == null) {
            throw new InvalidNodeException("invalid sequence number for node with id :" + node.getId());
        }//  ww  w .  j av  a2 s.  co  m

        if (StringUtils.isBlank(node.getIp())) {
            throw new InvalidNodeException("ip for node with id :" + node.getId());
        }

        if (StringUtils.isBlank(node.getPhysicalId())) {
            throw new InvalidNodeException("invalid sequence number for node with id :" + node.getId());
        }

        if (node.getPort() <= 0 || node.getPort() > 65535) {
            throw new InvalidNodeException("port is not valid for node with id :" + node.getId());
        }

        if (StringUtils.isBlank(node.getMachineId())) {
            throw new InvalidNodeException("machine id is empty for node with id :" + node.getId());
        }

        List<PhysicalNodeDO> nodes = nodesGroup.get(seq);
        if (nodes == null) {
            nodes = new ArrayList<PhysicalNodeDO>();
            nodesGroup.put(seq, nodes);
        }

        nodes.add(node);

        Set<StoreNodeSequenceEnum> ips = ipGroups.get(node.getIp());
        if (ips == null) {
            ips = new HashSet<StoreNodeSequenceEnum>();
        }

        if (StoreNodeSequenceEnum.isNormalSequence(seq)) {
            ips.add(seq);
        }

        ipGroups.put(node.getIp(), ips);
    }

    // validate logic id in one sequence:
    for (Map.Entry<StoreNodeSequenceEnum, List<PhysicalNodeDO>> oneSequenceNodes : nodesGroup.entrySet()) {
        //valid the logical id in one sequence.
        List<PhysicalNodeDO> nodes = oneSequenceNodes.getValue();
        List<Integer> allLogicalIds = new ArrayList<Integer>();
        for (PhysicalNodeDO node : nodes) {
            allLogicalIds.add(node.getLogicalId());
        }
        Collections.sort(allLogicalIds);

        for (int i = 0; i < allLogicalIds.size(); i++) {
            Integer logicalId = allLogicalIds.get(i);
            if (!logicalId.equals(i)) {
                throw new InvalidNodeException(
                        "invalid logical id: " + logicalId + " in sequece :" + oneSequenceNodes.getKey());
            }
        }

    }

    // the nodes in one machine cannot allocated to different normal sequence.
    for (Map.Entry<String, Set<StoreNodeSequenceEnum>> entry : ipGroups.entrySet()) {
        if (entry.getValue().size() > 1) {
            throw new InvalidNodeException("the nodes in machine (ip=" + entry.getKey()
                    + ") is allocated in different sequence" + entry.getValue());
        }
    }

    //Warning if there is no temp sequence.
    List<PhysicalNodeDO> tempNodes = nodesGroup.get(StoreNodeSequenceEnum.TEMP_SEQUENCE);
    if (tempNodes == null || tempNodes.isEmpty()) {
        SystemLogMonitor.error(MonitorEnum.ROUTER, MonitorWarnConstants.ROUTE_NO_TEMP_NODES);
    }
}

From source file:com.aurel.track.item.history.HistoryLoaderBL.java

/**
 * Get the list of HistoryValues from the map of Map<Integer, Map<Integer, HistoryValues>>
 * @param allHistoryMap/*from   w w  w. j  a  v a  2 s  . c o m*/
 * @param showCommentsInHistory whether the comment fields should be melt together with the most specific field 
 * from the transaction in this case allHistoryMap contains all history values (history and comment) 
 * @return
 */
public static List<HistoryValues> getHistoryValuesList(Map<Integer, Map<Integer, HistoryValues>> allHistoryMap,
        boolean showCommentsInHistory) {
    List<HistoryValues> historyList = new ArrayList<HistoryValues>();
    if (allHistoryMap != null) {
        Iterator<Integer> itrHistoryMap = allHistoryMap.keySet().iterator();
        while (itrHistoryMap.hasNext()) {
            Integer transactionID = itrHistoryMap.next();
            Map<Integer, HistoryValues> changesMap = allHistoryMap.get(transactionID);
            Set<Integer> changedFieldIDs = changesMap.keySet();
            Integer mostSpecificField = null;
            String transactionComment = null;
            if (changedFieldIDs.contains(SystemFields.INTEGER_COMMENT)) {
                //the transaction comments are shown in the comment column of the most specific fields's row
                //single comments, like any other explicit field are shown in a separate row but only if showCommentsInHistory = true
                if (changedFieldIDs.size() > 1) {
                    //a transaction which contains both a comment and other field changes: 
                    //save the comment to the transaction's most specific fields comment column
                    //but remove it as a row
                    HistoryValues commentHistoryValue = changesMap.remove(SystemFields.INTEGER_COMMENT);
                    transactionComment = (String) commentHistoryValue.getNewValue();
                    mostSpecificField = getMostSpecificFieldForComment(changedFieldIDs);
                }
                if (!showCommentsInHistory) {
                    //this comment is single one: remove if the comments are not shown in the history 
                    changesMap.remove(SystemFields.INTEGER_COMMENT);
                }
            }
            Iterator<Integer> itrChanges = changedFieldIDs.iterator();
            while (itrChanges.hasNext()) {
                Integer fieldID = itrChanges.next();
                HistoryValues histValues = changesMap.get(fieldID);
                if (mostSpecificField != null && fieldID.equals(mostSpecificField)) {
                    histValues.setTransactionComment(transactionComment);
                }
                historyList.add(histValues);
            }
        }
    }
    if (historyList.size() > 0) {
        // sort all history beans chronologically
        Collections.sort(historyList, new HistoryComparator());
    }
    return historyList;
}

From source file:com.bizintelapps.bugtracker.service.impl.ReportServiceImpl.java

@Override
public UserReportDto getUserSummary(Integer user, String requestedBy) {
    Users requestedUser = usersDao.findByUsername(requestedBy);
    UserReportDto dto = null;//ww  w .  j a  va  2  s. c om
    if (user == null || user.equals(0)) {
        user = requestedUser.getId();
    }
    // only admin, self can see graph
    if (user.equals(requestedUser.getId()) || requestedUser.isIsAdministrator()) {
        dto = (UserReportDto) userReportDao.findUserSummary(user);
    }
    return dto;
}

From source file:com.bizintelapps.bugtracker.service.impl.ReportServiceImpl.java

@Override
public UserReportDto getCurrentUserReport(Integer user, String requestedBy) {
    Users requestedUser = usersDao.findByUsername(requestedBy);
    UserReportDto dto = null;// w  w w  . j a  v a  2s.co m
    if (user == null || user.equals(0)) {
        user = requestedUser.getId();
    }
    // only admin, self can see graph
    if (user.equals(requestedUser.getId()) || requestedUser.isIsAdministrator()) {
        Calendar c = Calendar.getInstance();
        int month = c.get(Calendar.MONTH);
        int year = c.get(Calendar.YEAR);
        UserReport userReport = userReportDao.findByUserMonthAndYear(user, month, year);
        // copy for display
        dto = userReportDtoA.copyForDisplay(userReport);
    }
    return dto;
}

From source file:com.aurel.track.item.operation.ItemOperationSelect.java

@Override
public List<ReportBean> filter(List<ReportBean> reportBeans, Integer nodeObjectID) {
    List<ReportBean> result = new ArrayList<ReportBean>();
    if (nodeObjectID == null) {
        result.addAll(reportBeans);/*from   ww w  . java 2 s. c  o m*/
    } else {
        ReportBean reportBean;
        TWorkItemBean workItemBean;
        for (int i = 0; i < reportBeans.size(); i++) {
            reportBean = reportBeans.get(i);
            workItemBean = reportBean.getWorkItemBean();
            Object fieldValue = workItemBean.getAttribute(fieldID);
            if (nodeObjectID.equals(fieldValue)) {
                result.add(reportBean);
            }
        }
    }
    return result;
}

From source file:hr.fer.zemris.vhdllab.dao.impl.HistoryDaoTest.java

/**
 * Insert version, update version and created on can't be updated.
 *///  w ww.ja v  a2  s  .com
@Test
public void userIdTypeAndCreatedOnNotUpdateable() {
    dao.persist(entity);
    Integer newInsertVersion = 12;
    Integer newUpdateVersion = 32;
    Date newCreatedOn = CREATED_ON;
    history.setInsertVersion(newInsertVersion);
    history.setUpdateVersion(newUpdateVersion);
    history.setCreatedOn(newCreatedOn);
    dao.merge(entity);
    closeEntityManager(); // flush cache
    createEntityManager();
    HistoryTable loaded = (HistoryTable) entityManager.createQuery("select e from HistoryTable e")
            .getSingleResult();
    History loadedHistory = loaded.getHistory();
    assertFalse(newInsertVersion.equals(loadedHistory.getInsertVersion()));
    assertFalse(newUpdateVersion.equals(loadedHistory.getUpdateVersion()));
    assertFalse(newCreatedOn.equals(loadedHistory.getCreatedOn()));
}

From source file:com.clueride.domain.user.location.Location.java

public void removePuzzle(Integer puzzleId) {
    synchronized (SYNCH_LOCK) {
        List<Puzzle.Builder> remainingPuzzles = new ArrayList<>();
        for (Puzzle.Builder builder : puzzleBuilders) {
            if (!puzzleId.equals(builder.getId()) && builder != null) {
                remainingPuzzles.add(builder);
            }//from  w  w w  . ja  va  2 s .  co m
        }
        this.puzzleBuilders = ImmutableList.copyOf(remainingPuzzles);
    }
}

From source file:dk.dma.vessel.track.model.VesselTarget.java

/**
 * Update the static information fields from the AIS message
 * @param message the AIS message//from w w  w  .  j a  v a 2 s.c o  m
 * @param date the date of the message
 * @return if any fields were updated
 */
private boolean updateVesselStaticMessage(AisStaticCommon message, Date date) {

    // Check that this is a newer static update
    if (lastStaticReport != null && lastStaticReport.getTime() >= date.getTime()) {
        return false;
    }

    boolean updated = false;

    // Update the name
    String name = AisMessage.trimText(message.getName());
    if (StringUtils.isNotBlank(name) && !name.equals(this.name)) {
        this.name = name;
        updated = true;
    }

    // Update the call-sign
    String callsign = AisMessage.trimText(message.getCallsign());
    if (StringUtils.isNotBlank(callsign) && !callsign.equals(this.callsign)) {
        this.callsign = callsign;
        updated = true;
    }

    // Update the vessel type
    Integer vesselType = message.getShipType();
    if (!vesselType.equals(this.vesselType)) {
        this.vesselType = vesselType;
        updated = true;
    }

    if (message instanceof AisMessage5) {
        AisMessage5 msg5 = (AisMessage5) message;
        AisTargetDimensions dim = new AisTargetDimensions(msg5);

        // Update length
        Short length = (short) (dim.getDimBow() + dim.getDimStern());
        if (!length.equals(this.length)) {
            this.length = length;
            updated = true;
        }

        // Update width
        Short width = (short) (dim.getDimPort() + dim.getDimStarboard());
        if (!width.equals(this.width)) {
            this.width = width;
            updated = true;
        }

        // Update destination
        String destination = StringUtils.defaultIfBlank(AisMessage.trimText(msg5.getDest()), null);
        if (destination != null && !destination.equals(this.destination)) {
            this.destination = destination;
            updated = true;
        }

        // Update draught
        Float draught = msg5.getDraught() / 10.0f;
        if (msg5.getDraught() > 0 && !compare(draught, this.draught)) {
            this.draught = draught;
            updated = true;
        }

        // Update ETA
        Date eta = msg5.getEtaDate();
        if (eta != null && !eta.equals(this.eta)) {
            this.eta = eta;
            updated = true;
        }

        // Update IMO
        Long imo = msg5.getImo();
        if (msg5.getImo() > 0 && !imo.equals(this.imoNo)) {
            this.imoNo = imo;
            updated = true;
        }
    }

    // Only update lastStaticReport if any static field has been updated
    if (updated) {
        lastStaticReport = date;
    }

    return updated;
}