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:com.feilong.commons.core.lang.ObjectUtilTest.java

/**
 * Assert equals./* w w  w  . ja  v a  2  s .c om*/
 */
@Test
public final void assertEquals() {

    Long a = new Long(1L);
    Long b = new Long(1L);

    log.info((a == b) + "");
    log.info(a.equals(b) + "");

    User user = new User(1L);
    List<User> list = new ArrayList<User>();

    list.add(user);
    list.add(new User(1L));
    list.add(new User(new Long(1L)));
    list.add(new User(new Long(1L)));
    list.add(new User(new Long(1L)));

    for (User user2 : list) {
        log.info((user2.getId() == user.getId()) + "");
    }
}

From source file:com.jostrobin.battleships.view.frames.GameFrame.java

/**
 * Adds a ship to the currently attacked field. Used when a ship has been destroyed and we receive its complete
 * position./*from   w w  w  .j  av a 2  s  . c  om*/
 *
 * @param ship
 */
public void addShip(Long attackedClientId, Ship ship) {
    if (attackedClientId.equals(playerId)) {
        placementHelper.placeShipWithoutCheck(ship, ship.getPositionX(), ship.getPositionY());
        ship.setSelected(false);
    } else {
        gamePanel.addShip(attackedClientId, ship);

    }
}

From source file:io.onedecision.engine.decisions.impl.DecisionModelFactory.java

protected DmnModel getModelForTenant(Long id, String tenantId) {
    for (DmnModel dmnModel : repo) {
        if (tenantId.equals(dmnModel.getTenantId()) && id.equals(dmnModel.getShortId())) {
            return dmnModel;
        }//from   ww w. j a  v  a2  s. co  m
    }
    return null;
}

From source file:com.springinpractice.ch11.model.AbstractCI.java

@SuppressWarnings("unchecked")
@Override//from   ww w . j  av a  2  s .c  o  m
public boolean equals(Object o) {
    if (o == this) {
        return true;
    } else if (o == null || !o.getClass().equals(getClass())) {
        return false;
    } else {
        T that = (T) o;
        Long thisId = this.getId();
        Long thatId = that.getId();
        if (thisId == null || thatId == null) {
            return super.equals(that);
        } else {
            return thatId.equals(thisId);
        }
    }
}

From source file:edu.ur.file.mime.InMemoryMimeTypeService.java

/**
 * Remove the top media type from the system.
 * //ww  w . j  av a  2s  .c  o m
 * @see edu.ur.file.mime.BasicMimeTypeService#removeTopMediaType(java.lang.Long)
 */
public boolean removeTopMediaType(Long id) {
    TopMediaType tmt = null;

    for (TopMediaType topMediaType : topMediaTypes) {
        if (id.equals(topMediaType.getId())) {
            tmt = topMediaType;
        }
    }
    return topMediaTypes.remove(tmt);
}

From source file:org.bozzo.ipplan.web.AddressController.java

@RequestMapping(value = "/{ip}", method = RequestMethod.PUT, produces = { MediaType.APPLICATION_JSON_VALUE })
public HttpEntity<AddressResource> updateAddress(@PathVariable Integer infraId, @PathVariable Long subnetId,
        @PathVariable Long ip, @RequestBody @NotNull Address address) {
    Preconditions.checkArgument(subnetId.equals(address.getSubnetId()));
    Preconditions.checkArgument(ip.equals(address.getIp()));
    logger.info("update address: {}", address);
    Address addr = service.save(address);
    addr.setInfraId(infraId);/*from www  . j av  a2  s .co m*/
    return new ResponseEntity<>(assembler.toResource(addr), HttpStatus.CREATED);
}

From source file:com.square.adherent.noyau.util.PersonneUtil.java

/**
 * Filtre les emails correspondant  la nature passe en paramtre.
 * @param emails la liste d'emails  filtrer
 * @param idNatureEmail la nature de l'email recherch
 * @return la liste des emails filtrs correspondant  la nature passe en paramtre
 *//*w w w. jav a2s.com*/
public List<EmailDto> getEmailsByNature(List<EmailDto> emails, Long idNatureEmail) {
    final List<EmailDto> emailsFiltres = new ArrayList<EmailDto>();
    if (emails != null && !emails.isEmpty() && idNatureEmail != null) {
        for (EmailDto email : emails) {
            if (idNatureEmail.equals(email.getNatureEmail().getIdentifiant())) {
                emailsFiltres.add(email);
            }
        }
    }
    return emailsFiltres;
}

From source file:org.oncoblocks.centromere.sql.test.GenericJdbcRepositoryTests.java

@Test
public void countTest() {
    Long count = subjectRepository.count();
    Assert.notNull(count);
    Assert.isTrue(count.equals(5L));
}

From source file:com.github.ukase.service.BulkRenderer.java

public BulkStatus checkStatus(String id) {
    Long rendered = renderedPDFs.get(id);
    if (rendered == null) {
        return BulkStatus.ERROR;
    } else if (rendered.equals(Long.MAX_VALUE)) {
        return BulkStatus.ORDERED;
    }//from w w w.ja  v  a 2s  .  c o m
    return BulkStatus.PROCESSED;
}

From source file:Cursling.deleteNotification.java

public String _doDelete(String notification_name) {
    isdeleted = false;/*from  www  . j  a v a  2 s  .co m*/
    try {
        File inFile = new File(input_notification_file_del);

        if (!inFile.isFile()) {
            logger.info("Failed to Delete. Data file not found.");
            return ("failed");
        }
        storeUpdate = new File(input_notification_file_del);
        File tempFile = new File(inFile.getAbsolutePath() + ".tmp");
        BufferedReader br = new BufferedReader(new FileReader(input_notification_file_del));
        PrintWriter pw = new PrintWriter(new FileWriter(tempFile));
        String line = null;

        while ((line = br.readLine()) != null) {
            if (!line.equalsIgnoreCase("")) {
                if (line.startsWith(notification_name + "=") || line.startsWith(notification_name + " =")) {
                    isdeleted = true;
                    pw.flush();
                } else {
                    pw.println(line);
                    pw.flush();
                }
            } else { //do nothing
            }
        }
        pw.close();
        br.close();

        //Rename the new file to the filename the original file had.
        if (tempFile.canRead()) {
            Long before = storeUpdate.lastModified();
            FileUtils.copyFile(tempFile, storeUpdate);
            Long after = storeUpdate.lastModified();
            if (before.equals(after)) {
                logger.info("failed to delete Notification Group " + notification_name);
                return ("failed");
            } else if (isdeleted == true) {
                logger.info("Notification Group " + notification_name + " Deleted.");
                obj_convert._doConvert();
                return ("deleted");
            } else {
                logger.info("Failed to delete Notification Group " + notification_name
                        + " . Notification Group not found.");
                return ("not_found");
            }
        } else {
            logger.info("failed to delete Notification Group " + notification_name);
            return ("failed");
        }
    } catch (FileNotFoundException ex) {
        logger.info("failed to delete Notification Group " + notification_name);
        logger.error("Error : " + ex);
        return ("failed");
    } catch (IOException ex) {
        logger.info("failed to delete Notification Group " + notification_name);
        logger.error("Error : " + ex);
        return ("failed");
    }
}