/*
 *    Copyright (c) 2014-2017 Neil Ellis
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *          http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.sillelien.dollar.api;

import com.sillelien.dollar.api.collections.MultiMap;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Map;

public interface Scope {

    var addErrorHandler(@NotNull var handler);

    void clear();

    @NotNull var get(@NotNull String key, boolean mustFind);

    @Nullable var get(@NotNull String key);

    @Nullable var getConstraint(@NotNull String key);

    String getConstraintSource(@NotNull String key);



    @Nullable String getFile();

    @NotNull MultiMap<String, var> getListeners();

    @Nullable var getParameter(@NotNull String key);

    @Nullable Scope getScopeForKey(@NotNull String key);

    @Nullable Scope getScopeForParameters();

    @Nullable String getSource();

    @NotNull <T>  Map<String, T> getVariables();

    @NotNull var handleError(@NotNull Throwable t);

    boolean has(String key);

    boolean hasParameter(String key);

    void listen(@NotNull String key, @NotNull var listener);

    @Nullable var notify(@NotNull String variableName);

    void notifyScope(@NotNull String key, @NotNull var value);

    @NotNull var set(@NotNull String key, @NotNull var value, boolean readonly, @Nullable var constraint,
                     String constraintSource, boolean isVolatile,
            boolean fixed, boolean pure);

    @NotNull var setParameter(@NotNull String key, @NotNull var value);

    void setParent(@Nullable Scope scope);

    Scope getParent();

    boolean hasParent(Scope scope);

    boolean isRoot();
}

@@ -853,16 +853,29 @@
 cope %7B%0A%0A
+    @NotNull%0A
     var 
@@ -1091,24 +1091,38 @@
 ring key);%0A%0A
+    @Nullable%0A
     String g
@@ -1562,16 +1562,25 @@
 ean has(
+@NotNull 
 String k
@@ -1610,16 +1610,25 @@
 rameter(
+@NotNull 
 String k
@@ -1939,24 +1939,34 @@
             
+@Nullable 
 String const
@@ -1998,16 +1998,25 @@
 latile,%0A
+         
         
@@ -2163,24 +2163,38 @@
 pe scope);%0A%0A
+    @Nullable%0A
     Scope ge
@@ -2227,16 +2227,26 @@
 sParent(
+@Nullable 
 Scope sc

Work on new scope system.