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

com.jfreeman.attribute.EarlyBoundAttribute Maven / Gradle / Ivy

Go to download

A library for type-safe, tractable lazy evaluation and late binding in Java.

There is a newer version: 0.6.0
Show newest version
package com.jfreeman.attribute;

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

import com.jfreeman.lazy.Lazy;

/**
 * An attribute that is always written before it is read.
 *
 * @author jfreeman
 */
public class EarlyBoundAttribute
    implements Attribute
{
    private final Map> _attrs = new ConcurrentHashMap<>();

    /**
     * {@inheritDoc}
     *
     * May not be called for a node until after its value has been
     * {@link #put(Object, Lazy)}.
     */
    @Override
    public Lazy get(N node) {
        return _attrs.get(node);
    }

    /**
     * {@inheritDoc}
     *
     * Must be called before {@link #get(Object)} for the same node.
     */
    @Override
    public void put(N node, Lazy value) {
        _attrs.put(node, value);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy