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.eryansky.entity.base.User.java

/**
 * ??, ??','./*w w  w  .jav a 2  s.c  o  m*/
 * <br>?  "?" AppConstants.ROLE_SUPERADMIN
 */
@Transient
// ??.
public String getRoleNames() {
    Long superId = 1L;
    if (superId.equals(this.getId())) {
        return SecurityConstants.ROLE_SUPERADMIN;
    }
    return ConvertUtils.convertElementPropertyToString(roles, "name", ", ");
}

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

@RequestMapping(value = "/{subnetId}", method = RequestMethod.PUT, produces = {
        MediaType.APPLICATION_JSON_VALUE })
public HttpEntity<SubnetResource> updateSubnet(@PathVariable Integer infraId, @PathVariable Long subnetId,
        @RequestBody @NotNull Subnet subnet) {
    Preconditions.checkArgument(infraId.equals(subnet.getInfraId()));
    Preconditions.checkArgument(subnetId.equals(subnet.getId()));
    logger.info("update subnet: {}", subnet);

    if (!Netmask.isValidNetmask(subnet.getSize())) {
        throw new ApiException(ApiError.BAD_NETMASK);
    } else if (!IpAddress.isNetworkAddress(subnet.getIp(), subnet.getSize())) {
        throw new ApiException(ApiError.BAD_NETWORK);
    }//  ww w. j ava2  s. c  om

    Subnet sub = service.save(subnet);
    return new ResponseEntity<>(assembler.toResource(sub), HttpStatus.CREATED);
}

From source file:com.baidu.cc.web.filter.AuthCheckFilter.java

@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
        throws IOException, ServletException {

    HttpServletRequest request = (HttpServletRequest) servletRequest;
    HttpServletResponse response = (HttpServletResponse) servletResponse;

    String path = request.getServletPath();
    if (request.getParameter("method") != null) {
        path = path + "?method=" + request.getParameter("method");
    }//from   w w  w  . j  a  va  2s  .c  o  m

    // ?includePath ???
    if (UrlUtils.urlMatch(includePathv, path)) {
        if (StringUtils.contains("/project/editProject.action;/project/saveProject.action;", path)) {
            // ?????projectId?????
            String tmpProjectId = request.getParameter("reqParam.project.id");
            if (StringUtils.isEmpty(tmpProjectId)) {
                tmpProjectId = request.getParameter("reqParam.projectId");
            }
            Long pid = NumberUtils.toLong(tmpProjectId, 0);
            if (pid < 1L) {
                filterChain.doFilter(request, response);
                return;
            }
        }

        String authCheck = request.getParameter("authCheck");

        Long projectId = SysUtils.getProjectIdFromAuthcheck(authCheck);
        Long userId = SysUtils.getUserIdFromAuthcheck(authCheck);
        Long cookieUserId = SysUtils.getUserIdFromCookie(request);

        // authCheck??
        if (projectId == 0L || userId == 0L || !cookieUserId.equals(userId)
                || !accessSettingService.checkAuth(userId, SysUtils.ACCESS_SETTING_TYPE_PROJECT, projectId)) {
            throw new AuthException("??");
        }
    }
    filterChain.doFilter(request, response);
}

From source file:com.devnexus.ting.model.Event.java

public boolean hasSpeaker(Long speakerId) {
    Assert.notNull(speakerId, "The speakerId must not be null.");
    for (Speaker speaker : this.getSpeakers()) {
        if (speakerId.equals(speaker.getId())) {
            return true;
        }// w w w.ja v  a 2 s . c  om
    }
    return false;
}

From source file:service.ModuleService.java

public void changePosition(Long moduleId, Long newPosition, Long pkId) {
    Module Module = moduleDao.find(moduleId);
    Long groupId = Module.getGroup().getId();
    updatePositionsAndGetAvailable(groupId, pkId);
    TreeMap<Long, Module> map = new TreeMap();
    List<Module> modules = moduleDao.getActiveModules(groupId, pkId);
    Long oldPosition = Module.getPosition();
    for (Module m : modules) {
        Long GID = m.getId();
        if (GID.equals(moduleId)) {
            map.put(newPosition, m);/*from w w w .ja v  a  2s  . co  m*/
        } else {
            //  
            if (oldPosition > newPosition) {
                if (m.getPosition() < newPosition || m.getPosition() > oldPosition) {
                    map.put(m.getPosition(), m);
                } else {
                    map.put(m.getPosition() + 1, m);
                }
                //
            } else {
                if (m.getPosition() > newPosition || m.getPosition() < oldPosition) {
                    map.put(m.getPosition(), m);
                } else {
                    map.put(m.getPosition() - 1, m);
                }
            }
        }
    }
    for (Map.Entry<Long, Module> entry : map.entrySet()) {
        Long pos = entry.getKey();
        Module m = entry.getValue();
        m.setPosition(pos);
        if (validate(m)) {
            moduleDao.update(m);
        }
    }
}

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

@RequestMapping(method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE })
public HttpEntity<AddressResource> addAddress(@PathVariable Integer infraId, @PathVariable Long subnetId,
        @RequestBody @NotNull Address address) {
    Preconditions.checkArgument(infraId.equals(address.getInfraId()));
    Preconditions.checkArgument(subnetId.equals(address.getSubnetId()));
    logger.info("add new address: {}", address);
    if (address.getIp() == null) {
        Address freeAddress = this.service.findFreeAddressBySubnetId(subnetId);
        if (freeAddress == null) {
            throw new ApiException(ApiError.SUBNET_FULL);
        }/* ww  w  .j  a  va  2 s  .  com*/
        address.setIp(freeAddress.getIp());
    } else if (this.repository.exists(address.getIp())) {
        throw new ApiException(ApiError.IP_CONFLICT);
    }
    Address ip = service.save(address);
    ip.setInfraId(infraId);
    return new ResponseEntity<>(assembler.toResource(ip), HttpStatus.CREATED);
}

From source file:net.solarnetwork.node.settings.playpen.SettingsPlaypen.java

public void setLocationId(Long locationId) {
    if (this.location != null && locationId != null && !locationId.equals(this.location.getLocationId())) {
        this.location = null; // set to null so we re-fetch from server
    }/*www .  j  ava  2s  .c  o m*/
    this.locationId = locationId;
}

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

@RequestMapping(value = "/{rangeId}", method = RequestMethod.PUT, produces = {
        MediaType.APPLICATION_JSON_VALUE })
public HttpEntity<RangeResource> updateRange(@PathVariable Integer infraId, @PathVariable Long zoneId,
        @PathVariable Long rangeId, @RequestBody @NotNull Range range) {
    Preconditions.checkArgument(infraId.equals(range.getInfraId()));
    Preconditions.checkArgument(zoneId.equals(range.getZoneId()));
    Preconditions.checkArgument(rangeId.equals(range.getId()));

    if (!Netmask.isValidNetmask(range.getSize())) {
        throw new ApiException(ApiError.BAD_NETMASK);
    } else if (!IpAddress.isNetworkAddress(range.getIp(), range.getSize())) {
        throw new ApiException(ApiError.BAD_NETWORK);
    }//from   w w  w . j av  a  2s.  com

    logger.info("update range: {}", range);
    Range rang = service.save(range);
    return new ResponseEntity<>(assembler.toResource(rang), HttpStatus.CREATED);
}

From source file:com.redhat.rhn.domain.session.test.WebSessionFactoryTest.java

/**
 * Not ready for use yet.//from   ww w  .  j  a  v a 2 s .  c o  m
 */
public void xxxxUserOnSession() {
    WebSession s = WebSessionFactory.createSession();
    WebSessionFactory.save(s);
    s = (WebSession) reload(s);

    Long lastId = null;
    for (int i = 0; i < 50; i++) {
        Long userId = UserTestUtils.createUser("st" + Math.random() + System.currentTimeMillis(),
                "SessionTestOrg");
        assertFalse(userId.equals(lastId));
        s.setWebUserId(userId);
        User u = s.getUser();
        assertNotNull(u);
        assertEquals(userId, u.getId());
        lastId = userId;
        // s.setWebUserId(null);
        WebSessionFactory.save(s);
        // flushAndEvict(s);
        s = (WebSession) reload(s);
        TestCaseHelper.tearDownHelper();
    }
}

From source file:ome.services.scripts.test.ScriptRepoHelperTest.java

public void testFileModificationsUpdateTheSha1() throws Exception {
    path = generateFile();/*from   w w w  . j  a  v  a2  s  .  co  m*/
    files = helper.loadAll(false);
    Long oldID = files.get(0).getId();
    helper.write(path, "updated");
    files = helper.loadAll(true);
    Long newID = files.get(0).getId();
    assertFalse(oldID.equals(newID));
    String fsSha1 = path.sha1();
    String dbSha1 = files.get(0).getSha1();
    assertEquals(dbSha1, fsSha1);
}