/*******************************************************************************
 * Copyright (C) 2016 Push Technology 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.pushtechnology.diffusion.transform.adder;

import static com.pushtechnology.diffusion.transform.transformer.Transformers.identity;

import com.pushtechnology.diffusion.client.topics.details.TopicType;
import com.pushtechnology.diffusion.datatype.binary.Binary;
import com.pushtechnology.diffusion.datatype.json.JSON;

/**
 * Factory for creating instances of {@link TopicAdderBuilder}s.
 *
 * @author Push Technology Limited
 */
public final class TopicAdderBuilders {
    private TopicAdderBuilders() {
    }

    /**
     * Create a builder for {@link JSON} topic adders.
     * @return The builder
     */
    public static UnboundSafeTopicAdderBuilder<JSON, JSON> jsonTopicAdderBuilder() {
        return new UnboundSafeTopicAdderBuilderImpl<>(TopicType.JSON, identity(JSON.class));
    }

    /**
     * Create a builder for {@link Binary} topic adders.
     * @return The builder
     */
    public static UnboundSafeTopicAdderBuilder<Binary, Binary> binaryTopicAdderBuilder() {
        return new UnboundSafeTopicAdderBuilderImpl<>(TopicType.BINARY, identity(Binary.class));
    }
}

@@ -964,16 +964,68 @@
 icType;%0A
+import com.pushtechnology.diffusion.datatype.Bytes;%0A
 import c
@@ -1131,16 +1131,80 @@
 on.JSON;
+%0Aimport com.pushtechnology.diffusion.datatype.recordv2.RecordV2;
 %0A%0A/**%0A *
@@ -1382,32 +1382,517 @@
 ders() %7B%0A    %7D%0A%0A
+    /**%0A     * Create a builder for %7B@link JSON%7D topic adders.%0A     * @param valueType The value type%0A     * @param %3CV%3E The value type%0A     * @return The builder%0A     * @throws IllegalArgumentException If there is no known topic type for the value%0A     */%0A    public static %3CV extends Bytes%3E UnboundSafeTopicAdderBuilder%3CV, V%3E topicAdderBuilder(Class%3CV%3E valueType) %7B%0A        return new UnboundSafeTopicAdderBuilderImpl%3C%3E(topicTypeFromValueType(valueType), identity(valueType));%0A    %7D%0A%0A
     /**%0A     * C
@@ -2451,11 +2451,1017 @@
 );%0A    %7D
+%0A%0A    /**%0A     * Returns the topic type for a given value type.%0A     * @throws IllegalArgumentException If there is no known topic type for the value%0A     */%0A    /*package*/ static TopicType topicTypeFromValueType(Class%3C?%3E valueType) %7B%0A        if (JSON.class.isAssignableFrom(valueType)) %7B%0A            return TopicType.JSON;%0A        %7D%0A        else if (Binary.class.isAssignableFrom(valueType)) %7B%0A            return TopicType.BINARY;%0A        %7D%0A        else if (String.class.isAssignableFrom(valueType)) %7B%0A            return TopicType.STRING;%0A        %7D%0A        else if (Double.class.isAssignableFrom(valueType)) %7B%0A            return TopicType.DOUBLE;%0A        %7D%0A        else if (Long.class.isAssignableFrom(valueType)) %7B%0A            return TopicType.INT64;%0A        %7D%0A        else if (RecordV2.class.isAssignableFrom(valueType)) %7B%0A            return TopicType.RECORD_V2;%0A        %7D%0A        else %7B%0A            throw new IllegalArgumentException(%22The topic type for %22 + valueType + %22 is unknown%22);%0A        %7D%0A    %7D
 %0A%7D%0A

Add a method that allows topic adders to be add from a provided value type.