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:eagle.storage.jdbc.entity.JdbcEntitySerDeserHelper.java

/**
 *
 * @param row//from   ww w  . j a  va 2s. c om
 * @param entityDefinition
 * @param <E>
 * @return
 * @throws IllegalAccessException
 * @throws InstantiationException
 * @throws InvocationTargetException
 * @throws NoSuchMethodException
 */
public static <E extends TaggedLogAPIEntity> E buildEntity(Map<String, Object> row,
        JdbcEntityDefinition entityDefinition) throws IllegalAccessException, InstantiationException,
        InvocationTargetException, NoSuchMethodException {
    EntityDefinition ed = entityDefinition.getInternal();

    Class<? extends TaggedLogAPIEntity> clazz = ed.getEntityClass();
    if (clazz == null) {
        throw new NullPointerException("Entity class of service " + ed.getService() + " is null");
    }

    TaggedLogAPIEntity obj = clazz.newInstance();
    Map<String, Qualifier> map = ed.getDisplayNameMap();
    for (Map.Entry<String, Object> entry : row.entrySet()) {
        // timestamp;
        if (JdbcConstants.TIMESTAMP_COLUMN_NAME.equals(entry.getKey())) {
            obj.setTimestamp((Long) entry.getValue());
            continue;
        }

        // set metric as prefix for generic metric
        if (entityDefinition.getInternal().getService().equals(GenericMetricEntity.GENERIC_METRIC_SERVICE)
                && JdbcConstants.METRIC_NAME_COLUMN_NAME.equals(entry.getKey())) {
            obj.setPrefix((String) entry.getValue());
            continue;
        }

        // rowkey: uuid
        if (JdbcConstants.ROW_KEY_COLUMN_NAME.equals(entry.getKey())) {
            obj.setEncodedRowkey((String) entry.getValue());
            continue;
        }

        Qualifier q = map.get(entry.getKey().toLowerCase());
        if (q == null) {
            // if it's not pre-defined qualifier, it must be tag unless it's a bug
            if (obj.getTags() == null) {
                obj.setTags(new HashMap<String, String>());
            }
            obj.getTags().put(entry.getKey(), (String) entry.getValue());
            continue;
        }

        // parse different types of qualifiers
        String fieldName = q.getDisplayName();
        // PropertyDescriptor pd = PropertyUtils.getPropertyDescriptor(obj, fieldName);
        PropertyDescriptor pd = getPropertyDescriptor(obj, fieldName);
        if (entry.getValue() != null) {
            pd.getWriteMethod().invoke(obj, entry.getValue());
        }
    }

    if (!entityDefinition.getInternal().getService().equals(GenericMetricEntity.GENERIC_METRIC_SERVICE)) {
        obj.setPrefix(entityDefinition.getInternal().getPrefix());
    }
    return (E) obj;
}

From source file:net.darkmist.alib.res.PkgRes.java

public PkgRes(Class<?> cls) {
    if (cls == null)
        throw new NullPointerException("cls is null");
    this.loader = cls.getClassLoader();
    prefix = appendResourcePathPrefixFor(null, cls).toString();
}

From source file:org.usrz.libs.riak.response.JsonContentHandler.java

public JsonContentHandler(ObjectMapper mapper, Class<T> type) {
    if (mapper == null)
        throw new NullPointerException("Null object mapper");
    if (type == null)
        throw new NullPointerException("Null type");
    this.mapper = mapper;
    this.type = type;
}

From source file:it.cnr.isti.hlt.processfast.data.RecursiveIndexFileLineIteratorProvider.java

public RecursiveIndexFileLineIteratorProvider(String baseDir, String regexInclusion) {
    if (baseDir == null)
        throw new NullPointerException("The collection is 'null'");

    files = listFiles(baseDir, regexInclusion);
}