/*
 * Thrifty
 *
 * Copyright (c) Microsoft Corporation
 *
 * 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
 *
 * THIS CODE IS PROVIDED ON AN  *AS IS* BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
 * WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE,
 * FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT.
 *
 * See the Apache Version 2.0 License for specific language governing permissions and limitations under the License.
 */
package com.microsoft.thrifty.schema;

import com.google.common.base.Preconditions;

import java.util.Map;

/**
 * The base type of all UserElement-derived builders.
 *
 * @param <TElement> the type of element being built
 * @param <TBuilder> the most-derived type of the builder
 */
@SuppressWarnings("unchecked")
abstract class AbstractUserElementBuilder<
        TElement extends UserElement,
        TBuilder extends AbstractUserElementBuilder<TElement, TBuilder>> {
    UserElementMixin mixin;

    AbstractUserElementBuilder(UserElementMixin mixin) {
        this.mixin = mixin;
    }

    public TBuilder name(String name) {
        Preconditions.checkNotNull(name, "name");
        mixin = mixin.toBuilder().name(name).build();
        return (TBuilder) this;
    }

    public TBuilder location(Location location) {
        Preconditions.checkNotNull(location, "location");
        mixin = mixin.toBuilder().location(location).build();
        return (TBuilder) this;
    }

    public TBuilder documentation(String documentation) {
        Preconditions.checkNotNull(documentation, "documentation");
        mixin = mixin.toBuilder().documentation(documentation).build();
        return (TBuilder) this;
    }

    public TBuilder annotations(Map<String, String> annotations) {
        Preconditions.checkNotNull(annotations, "annotations");
        mixin = mixin.toBuilder().annotations(annotations).build();
        return (TBuilder) this;
    }

    public abstract TElement build();
}

@@ -1181,16 +1181,17 @@
 der%3E%3E %7B%0A
+%0A
     User
@@ -2162,32 +2162,403 @@
 r) this;%0A    %7D%0A%0A
+    public TBuilder type(TElement type) %7B%0A        Preconditions.checkNotNull(type, %22type%22);%0A        mixin = mixin.toBuilder()%0A                .name(type.name())%0A                .location(type.location())%0A                .documentation(type.documentation())%0A                .annotations(type.annotations())%0A                .build();%0A        return (TBuilder) this;%0A    %7D%0A%0A
     public abstr

Add convenience type() to user element builder (#98)