Example usage for java.lang NullPointerException NullPointerException

List of usage examples for java.lang NullPointerException NullPointerException

Introduction

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

Prototype

public NullPointerException(String s) 

Source Link

Document

Constructs a NullPointerException with the specified detail message.

Usage

From source file:edu.cornell.mannlib.vitro.webapp.dao.filtering.filters.FilterByRoleLevelPermission.java

private static Permission getDefaultPermission(ServletContext ctx) {
    if (ctx == null) {
        throw new NullPointerException("context may not be null.");
    }//from  w ww.  j  av  a 2 s  . c o  m

    return PermissionRegistry.getRegistry(ctx).getPermission(DisplayByRolePermission.NAMESPACE + "Public");
}

From source file:ch.ralscha.extdirectspring_itest.ExceptionFormPostService.java

@ExtDirectMethod(value = ExtDirectMethodType.FORM_POST, group = "itest_upload_service")
public ExtDirectFormPostResult throwAException(@SuppressWarnings("unused") HttpServletRequest request) {
    throw new NullPointerException("a null pointer");
}

From source file:com.jevontech.wabl.services.implementation.UserDetailsServiceImpl.java

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {

    if (userRepository == null) {
        throw new NullPointerException("userRepository== null");

    }/*from  w ww . j  a v  a2  s  .  co  m*/

    User user = this.userRepository.findByUsername(username);

    if (user == null) {
        throw new UsernameNotFoundException(String.format("No user found with username '%s'.", username));
    } else {
        return SecurityUserFactory.create(user);
    }
}

From source file:cz.muni.fi.pa165.deliveryservice.dao.jpa.JPACourierDAO.java

@Override
public void createCourier(Courier courier) {
    if (courier == null) {
        throw new NullPointerException("Courier argument can't be null");
    }//from www .ja  v  a  2  s  .  c  o m
    if (courier.getId() != null) {
        throw new IllegalStateException("Trying to create courier with id assigned");
    }

    em.persist(courier);
}

From source file:com.eas.client.reports.JSDynaBean.java

@Override
public boolean contains(String aName, String aKey) {
    Object value = delegate.getMember(aName);
    if (value == null) {
        throw new NullPointerException("No mapped value for '" + aName + "(" + aKey + ")'");
    } else if (value instanceof JSObject) {
        if (!((JSObject) value).isFunction()) {
            return ((JSObject) value).hasMember(aKey);
        } else {/*from  w  w w  . j  a va2s . co m*/
            return false;
        }
    } else if (value instanceof Map) {
        return ((Map) value).containsKey(aKey);
    } else {
        throw new IllegalArgumentException("Non-mapped property for '" + aName + "(" + aKey + ")'");
    }
}

From source file:cz.muni.pa165.carparkapp.serviceImpl.BranchServiceImpl.java

@Override
public BranchDTO addBranch(BranchDTO branchdto) {
    if (branchdto == null)
        throw new NullPointerException("Argument cannot be null");

    Branch branch = mapper.map(branchdto, Branch.class);
    branchDAO.createBranch(branch);//  www .  j  ava 2 s.  com

    branchdto.setId(branch.getId());

    return branchdto;
}

From source file:edu.dfci.cccb.mev.dataset.domain.mock.MockUrlInput.java

public MockUrlInput(URL url) {
    if (url == null)
        throw new NullPointerException("URL cannot be null");
    this.url = url;
}

From source file:cz.muni.pa165.carparkapp.DAOImpl.BranchDAOImpl.java

@Override
public boolean updateBranch(Branch branch) {
    if (branch == null)
        throw new NullPointerException("Argument cannot be null");

    if (findBranch(branch.getId()) == null)
        return false;

    em.merge(branch);/*  www  .  j a v  a  2 s  .  c om*/
    return true;
}

From source file:org.runway.employees.service.EmployeeServiceImpl.java

public Employee add(Employee employee) {

    if (employee == null) {
        throw new NullPointerException("employee is null");
    }/* w  w w.j a va2 s.c o  m*/
    if (employee.getId() == 0) {
        long id = employeeDao.generateEmployeeId();
        employee.setId(id);
    }

    employeeDao.add(employee);

    return employee;
}

From source file:org.atemsource.atem.impl.json.attribute.AnyAttribute.java

@Override
public Object getValue(Object entity) {
    ObjectNode node = (ObjectNode) entity;
    if (node.isNull()) {
        throw new NullPointerException("entity is null");
    } else {/*w w  w.j a va  2  s.com*/
        JsonNode jsonNode = node.get(getCode());
        if (jsonNode == null || jsonNode.isNull()) {
            return null;
        } else {
            return JsonUtils.convertToJava(jsonNode);
        }
    }
}