// Path: hydra-composer/src/main/java/com/flipkart/hydra/composer/exception/ComposerEvaluationException.java
// public class ComposerEvaluationException extends Exception {
// 
//     public ComposerEvaluationException() {
//         super();
//     }
// 
//     public ComposerEvaluationException(String message) {
//         super(message);
//     }
// 
//     public ComposerEvaluationException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public ComposerEvaluationException(Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: hydra-expression/src/main/java/com/flipkart/hydra/expression/Expression.java
// public interface Expression {
// 
//     public Object calculate(Map<String, Object> values) throws ExpressionEvaluationException;
// 
//     public List<String> getDependencies();
// }
// 
// Path: hydra-expression/src/main/java/com/flipkart/hydra/expression/exception/ExpressionEvaluationException.java
// public class ExpressionEvaluationException extends Exception {
// 
//     public ExpressionEvaluationException() {
//         super();
//     }
// 
//     public ExpressionEvaluationException(String message) {
//         super(message);
//     }
// 
//     public ExpressionEvaluationException(String expected, String found) {
//         super("Expected " + expected + ", Found " + found);
//     }
// 
//     public ExpressionEvaluationException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public ExpressionEvaluationException(Throwable cause) {
//         super(cause);
//     }
// }


import com.flipkart.hydra.composer.exception.ComposerEvaluationException;
import com.flipkart.hydra.expression.Expression;
import com.flipkart.hydra.expression.exception.ExpressionEvaluationException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/*
 * Copyright 2015 Flipkart Internet, pvt ltd.
 *
 * 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.flipkart.hydra.composer.utils;



public class CompositionEvaluator {

    public static Object evaluate(Object context, Map<String, Object> values) throws ComposerEvaluationException {
        if (context instanceof Expression) {
            try {
                return ((Expression) context).calculate(values);
            } catch (ExpressionEvaluationException e) {
// Path: hydra-composer/src/main/java/com/flipkart/hydra/composer/exception/ComposerEvaluationException.java
// public class ComposerEvaluationException extends Exception {
// 
//     public ComposerEvaluationException() {
//         super();
//     }
// 
//     public ComposerEvaluationException(String message) {
//         super(message);
//     }
// 
//     public ComposerEvaluationException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public ComposerEvaluationException(Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: hydra-expression/src/main/java/com/flipkart/hydra/expression/Expression.java
// public interface Expression {
// 
//     public Object calculate(Map<String, Object> values) throws ExpressionEvaluationException;
// 
//     public List<String> getDependencies();
// }
// 
// Path: hydra-expression/src/main/java/com/flipkart/hydra/expression/exception/ExpressionEvaluationException.java
// public class ExpressionEvaluationException extends Exception {
// 
//     public ExpressionEvaluationException() {
//         super();
//     }
// 
//     public ExpressionEvaluationException(String message) {
//         super(message);
//     }
// 
//     public ExpressionEvaluationException(String expected, String found) {
//         super("Expected " + expected + ", Found " + found);
//     }
// 
//     public ExpressionEvaluationException(String message, Throwable cause) {
//         super(message, cause);
//     }
// 
//     public ExpressionEvaluationException(Throwable cause) {
//         super(cause);
//     }
// }


// Path: hydra-composer/src/main/java/com/flipkart/hydra/composer/utils/CompositionEvaluator.java
import com.flipkart.hydra.composer.exception.ComposerEvaluationException;
import com.flipkart.hydra.expression.Expression;
import com.flipkart.hydra.expression.exception.ExpressionEvaluationException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/*
 * Copyright 2015 Flipkart Internet, pvt ltd.
 *
 * 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.flipkart.hydra.composer.utils;



public class CompositionEvaluator {

    public static Object evaluate(Object context, Map<String, Object> values) throws ComposerEvaluationException {
        if (context instanceof Expression) {
            try {
                return ((Expression) context).calculate(values);
            } catch (ExpressionEvaluationException e) {
                throw new ComposerEvaluationException("Unable to evaluate composer.", e);