/*
 * Copyright 2015 Google Inc. All Rights Reserved.
 *
 * 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.google.doubleclick.openrtb;

import com.google.doubleclick.util.DoubleClickMacros;
import com.google.openrtb.snippet.OpenRtbMacros;
import com.google.openrtb.snippet.OpenRtbSnippetProcessor;
import com.google.openrtb.snippet.SnippetMacroType;
import com.google.openrtb.snippet.SnippetProcessor;
import com.google.openrtb.snippet.SnippetProcessorContext;

import javax.inject.Singleton;

/**
 * {@link SnippetProcessor} for DoubleClick Ad Exchange.
 */
@Singleton
public class DoubleClickSnippetProcessor extends OpenRtbSnippetProcessor {
  public static final DoubleClickSnippetProcessor DC_NULL = new DoubleClickSnippetProcessor() {
    @Override public String process(SnippetProcessorContext ctx, String snippet) {
      return SnippetProcessor.NULL.process(ctx, snippet);
    }};

  @Override protected void processMacroAt(
      SnippetProcessorContext ctx, StringBuilder sb, SnippetMacroType macroDef) {
    if (macroDef instanceof OpenRtbMacros) {
      switch ((OpenRtbMacros) macroDef) {
        case AUCTION_PRICE: {
          sb.append(DoubleClickMacros.WINNING_PRICE.key());
          return;
        }

        default:
      }
    }

    super.processMacroAt(ctx, sb, macroDef);
  }
}

@@ -1487,26 +1487,8 @@
 ctx,
- StringBuilder sb,
  Sni
@@ -1509,24 +1509,24 @@
 macroDef) %7B%0A
+
     if (macr
@@ -1640,18 +1640,29 @@
         
-sb
+ctx.builder()
 .append(
@@ -1758,24 +1758,24 @@
    %7D%0A    %7D%0A%0A
+
     super.pr
@@ -1795,12 +1795,8 @@
 ctx,
- sb,
  mac

Update for SnippetProcessor changes