/*
 * $Id$
 *
 * File is automatically generated by the Xtext language generator.
 * Do not change it.
 *
 * SARL is an general-purpose agent programming language.
 * More details on http://www.sarl.io
 *
 * Copyright (C) 2014-2026 SARL.io, the original authors and main authors.
 *
 * 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 io.sarl.lang.codebuilder.appenders;

import io.sarl.lang.codebuilder.builders.ITypeParameterBuilder;
import java.io.IOException;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtend.core.xtend.XtendExecutable;
import org.eclipse.xtend.core.xtend.XtendTypeDeclaration;
import org.eclipse.xtext.common.types.JvmType;
import org.eclipse.xtext.common.types.JvmTypeParameter;
import org.eclipse.xtext.common.types.JvmTypeParameterDeclarator;
import org.eclipse.xtext.common.types.JvmTypeReference;
import org.eclipse.xtext.common.types.access.IJvmTypeProvider;
import org.eclipse.xtext.xbase.compiler.ISourceAppender;
import org.eclipse.xtext.xbase.lib.Pure;

/** Appender of a Sarl type parameter.
	 * @see "TypeParameterBuilderFragment.java : appendTo : 170"
 */
@SuppressWarnings("all")
public class TypeParameterSourceAppender extends AbstractSourceAppender implements ITypeParameterBuilder {

	private final ITypeParameterBuilder builder;

	public TypeParameterSourceAppender(ITypeParameterBuilder builder) {
		this.builder = builder;
	}

	/** Fill the given receiver with the serialization of the element that is associated to this appender.
	 *
	 * @param appender the receiver of the source code.
	 * @throws IOException if there is error during the serialization.
	 * @see "AbstractSubCodeBuilderFragment.java : appendTo : 550"
	 */
	public void build(ISourceAppender appender) throws IOException {
		build(this.builder.getJvmTypeParameter(), appender);
	}

	/** Find the reference to the type with the given name.
	 * @param typeName the fully qualified name of the type
	 * @return the type reference.
	 * @see "TypeParameterBuilderFragment.java : appendTo : 239"
	 */
	public JvmTypeReference newTypeRef(String typeName) {
		return this.builder.newTypeRef(typeName);
	}

	/** Find the reference to the type with the given name.
	 * @param context the context for the type reference use
	 * @param typeName the fully qualified name of the type
	 * @return the type reference.
	 * @see "TypeParameterBuilderFragment.java : appendTo : 267"
	 */
	public JvmTypeReference newTypeRef(Notifier context, String typeName) {
		return this.builder.newTypeRef(context, typeName);
	}

	/** Find the reference to the type with the given type parameters.
	 * @param type the type to reference
	 * @param args the type parameters to add to the to reference to the given type
	 * @return the type reference.
	 * @see "TypeParameterBuilderFragment.java : appendTo : 297"
	 */
	public JvmTypeReference newTypeRef(JvmType type, JvmTypeReference... args) {
		return this.builder.newTypeRef(type, args);
	}

	/** Find the reference to the type with the given type parameters.
	 * @param type the type to reference
	 * @param args the type parameters to add to the to reference to the given type
	 * @return the type reference.
	 * @see "TypeParameterBuilderFragment.java : appendTo : 329"
	 */
	public JvmTypeReference newTypeRef(Class type, JvmTypeReference... args) {
		return this.builder.newTypeRef(type, args);
	}

	/** Find the reference to the type with the given type parameters.
	 * @param context the context in which the type is defined
	 * @param type the type to reference
	 * @param args the type parameters to add to the to reference to the given type
	 * @return the type reference.
	 * @see "TypeParameterBuilderFragment.java : appendTo : 363"
	 */
	public JvmTypeReference newTypeRef(Notifier context, Class type, JvmTypeReference... args) {
		return this.builder.newTypeRef(context, type, args);
	}

	/** Initialize the type parameter.
	 * <p>Caution: This initialization function does not add the type parameter in its container.
	 * The container is responsible of adding the type parameter in its internal object.
	 * However, this function sets the declarator of the type parameter by calling
	 * {@link JvmTypeParameter#setDeclarator(JvmTypeParameterDeclarator)}.
	 * @param context the container of the type parameter.
	 * @param declarator the container of the type parameter.
	 * @param name the name of the type parameter.
	 * @param typeContext the provider of types or null.
	 * @see "TypeParameterBuilderFragment.java : appendTo : 408"
	 */
	public void eInit(XtendTypeDeclaration context, JvmTypeParameterDeclarator declarator, String name, IJvmTypeProvider typeContext) {
		this.builder.eInit(context, declarator, name, typeContext);
	}

	/** Initialize the type parameter.
	 * <p>Caution: This initialization function does not add the type parameter in its container.
	 * The container is responsible of adding the type parameter in its internal object.
	 * However, this function sets the declarator of the type parameter by calling
	 * {@link JvmTypeParameter#setDeclarator(JvmTypeParameterDeclarator)}.
	 * @param context the container of the type parameter.
	 * @param declarator the container of the type parameter.
	 * @param name the name of the type parameter.
	 * @param typeContext the provider of types or null.
	 * @see "TypeParameterBuilderFragment.java : appendTo : 455"
	 */
	public void eInit(XtendExecutable context, JvmTypeParameterDeclarator declarator, String name, IJvmTypeProvider typeContext) {
		this.builder.eInit(context, declarator, name, typeContext);
	}

	/** Replies the context for type resolution.
	 * @return the context or {@code null} if the Ecore object is the context.
	 * @see "TypeParameterBuilderFragment.java : appendTo : 546"
	 */
	public IJvmTypeProvider getTypeResolutionContext() {
		return this.builder.getTypeResolutionContext();
	}

	/** Replies the created parameter.
	 *
	 * @return the parameter.
	 * @see "TypeParameterBuilderFragment.java : appendTo : 565"
	 */
	@Pure
	public JvmTypeParameter getJvmTypeParameter() {
		return this.builder.getJvmTypeParameter();
	}

	/** Replies a reference to the created parameter.
	 *
	 * @return the reference to the parameter.
	 * @see "TypeParameterBuilderFragment.java : appendTo : 602"
	 */
	@Pure
	public JvmTypeReference getJvmTypeParameterReference() {
		return this.builder.getJvmTypeParameterReference();
	}

	/** Replies the resource to which the type parameter is attached.
	 * @see "TypeParameterBuilderFragment.java : appendTo : 635"
	 */
	@Pure
	public Resource eResource() {
		return getJvmTypeParameter().eResource();
	}

	/** Dispose the resource.
	 * @see "TypeParameterBuilderFragment.java : appendTo : 698"
	 */
	public void dispose() {
		this.builder.dispose();
	}

	/** Add upper type bounds.
	 * @param type the type.
	 * @return {@code this}
	 * @see "TypeParameterBuilderFragment.java : appendTo : 716"
	 */
	public ITypeParameterBuilder addUpperConstraint(String type) {
		this.builder.addUpperConstraint(type);
		return this;
	}

	/** Add upper type bounds.
	 * @param type the type.
	 * @return {@code this}
	 * @see "TypeParameterBuilderFragment.java : appendTo : 749"
	 */
	public ITypeParameterBuilder addUpperConstraint(JvmTypeReference type) {
		this.builder.addUpperConstraint(type);
		return this;
	}

	/** Add lower type bounds.
	 * @param type the type.
	 * @return {@code this}
	 * @see "TypeParameterBuilderFragment.java : appendTo : 801"
	 */
	public ITypeParameterBuilder addLowerConstraint(String type) {
		this.builder.addLowerConstraint(type);
		return this;
	}

	/** Add lower type bounds.
	 * @param type the type.
	 * @return {@code this}
	 * @see "TypeParameterBuilderFragment.java : appendTo : 834"
	 */
	public ITypeParameterBuilder addLowerConstraint(JvmTypeReference type) {
		this.builder.addLowerConstraint(type);
		return this;
	}

}

