All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rx.bean.AbstractAttributes Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package org.rx.bean;

import org.rx.core.Constants;
import org.rx.core.Extends;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@SuppressWarnings(Constants.NON_UNCHECKED)
public class AbstractAttributes implements Extends {
    private static final long serialVersionUID = -800222176830684588L;
    private Map attrs;

    protected  Map initialAttrs() {
        return new ConcurrentHashMap<>();
    }

    @Override
    public  TV attr(TK key) {
        if (attrs == null) {
            return null;
        }
        return (TV) attrs.get(key);
    }

    @Override
    public  void attr(TK key, TV value) {
        if (attrs == null) {
            if (value == null) {
                return;
            }
            attrs = initialAttrs();
        }
        if (value == null) {
            attrs.remove(key);
        } else {
            attrs.put(key, value);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy