/*
 * Copyright (c) 2004-2017, by Alex Leigh.
 * All rights reserved.
 *
 * THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE
 * The copyright notice above does not evidence any
 * actual or intended publication of such source code.
 */

package lc.mecha.lang;

import java.util.Map;
import java.util.Set;

/**
 * This interface describes a dynamic object, who's fields are not necessarily
 * determined until runtime. For a default implementation of this interface, see
 * <code>SimpleDynamicObject</code>.
 *
 * @author Alex Leigh
 */

public interface DynamicObject {

    Set<String> propertyStringNamesWithValues();

    /**
     * Fetch the given property from the object. If the property is not found,
     * or is null, then null is returned. How the value is stored in the object
     * is ultimately up to it.
     *
     * @param property
     * @return
     */
    Object get(String property);

    /**
     * Return a set containing a list of all the properties currently stored in
     * this dynamic object.
     *
     * @return
     */
    Set<String> propertyNames();

    /**
     * Get a value who's property is not specifically bound; this method is
     * called by get() implementations as a last-resort.
     *
     * @param property
     * @return
     */
    Object unbound(String property);

    /**
     * Set the given property to be the given value in the object. How the value
     * is stored in the object is ultimately up to it.
     *
     * @param property
     * @param value
     */
    void set(String property, Object value);

    void setAll(Map<String, Object> map);

    /**
     * Set a value who's property is not specifically bound; this method is
     * called by set() implementations as a last-resort.
     *
     * @param property
     * @param value
     */
    void setUnbound(String property, Object value);
}
