// Path: coopr-server/src/main/java/co/cask/coopr/macro/eval/Evaluator.java
// public interface Evaluator {
// 
//   /**
//    * Evaluate the macro expression on the given node of the given cluster, with the given cluster nodes.
//    * Returns null if the macro does not expand to anything.
//    *
//    * @param cluster Cluster the macro is being expanded for.
//    * @param clusterNodes Nodes in the cluster the macro is being expanded for.
//    * @param node The cluster node that the macro is being expanded for.
//    * @return Evaluated macro expression.
//    * @throws IncompleteClusterException if the cluster does not contain the information required to evaluate the macro.
//    */
//   List<String> evaluate(Cluster cluster, Set<Node> clusterNodes, Node node) throws IncompleteClusterException;
// }


import co.cask.coopr.cluster.Cluster;
import co.cask.coopr.cluster.Node;
import co.cask.coopr.macro.eval.Evaluator;
import com.google.common.base.Objects;
import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;
/*
 * Copyright © 2012-2014 Cask Data, Inc.
 *
 * 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 co.cask.coopr.macro;



/**
 * An expression represents a single macro. It has a type and a name that are used to lookup the substitute for the
 * macro. Currently, the substitute is either the list of ip addresses or the list of host names of the nodes that the
 * named service runs on. By default, the substitute is returned as a comma-separated list. The list separator can be
 * overridden by passing a different one to the constructor. Also, optionally each element in the substitute can be
 * formatted according to a format string. The actual element is inserted by replacing the $ in the format string. The
 * $ sign can be escaped by preceding it with another $.
 */
public class Expression {
  private static final String DEFAULT_SEPARATOR = ",";
  private static final char PLACEHOLDER = '$';
// Path: coopr-server/src/main/java/co/cask/coopr/macro/eval/Evaluator.java
// public interface Evaluator {
// 
//   /**
//    * Evaluate the macro expression on the given node of the given cluster, with the given cluster nodes.
//    * Returns null if the macro does not expand to anything.
//    *
//    * @param cluster Cluster the macro is being expanded for.
//    * @param clusterNodes Nodes in the cluster the macro is being expanded for.
//    * @param node The cluster node that the macro is being expanded for.
//    * @return Evaluated macro expression.
//    * @throws IncompleteClusterException if the cluster does not contain the information required to evaluate the macro.
//    */
//   List<String> evaluate(Cluster cluster, Set<Node> clusterNodes, Node node) throws IncompleteClusterException;
// }


// Path: coopr-server/src/main/java/co/cask/coopr/macro/Expression.java
import co.cask.coopr.cluster.Cluster;
import co.cask.coopr.cluster.Node;
import co.cask.coopr.macro.eval.Evaluator;
import com.google.common.base.Objects;
import java.util.List;
import java.util.Set;
import javax.annotation.Nullable;

/*
 * Copyright © 2012-2014 Cask Data, Inc.
 *
 * 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 co.cask.coopr.macro;



/**
 * An expression represents a single macro. It has a type and a name that are used to lookup the substitute for the
 * macro. Currently, the substitute is either the list of ip addresses or the list of host names of the nodes that the
 * named service runs on. By default, the substitute is returned as a comma-separated list. The list separator can be
 * overridden by passing a different one to the constructor. Also, optionally each element in the substitute can be
 * formatted according to a format string. The actual element is inserted by replacing the $ in the format string. The
 * $ sign can be escaped by preceding it with another $.
 */
public class Expression {
  private static final String DEFAULT_SEPARATOR = ",";
  private static final char PLACEHOLDER = '$';
  private final Evaluator evaluator;