All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.speedment.common.codegen.Meta Maven / Gradle / Ivy

Go to download

A Speedment bundle that shades all dependencies into one jar. This is useful when deploying an application on a server.

The newest version!
/*
 *
 * Copyright (c) 2006-2019, Speedment, 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.speedment.common.codegen;

import com.speedment.common.codegen.internal.MetaImpl;

/**
 * Meta information about the generation process.
 *
 * @param  the model type
 * @param  the result type
 * @author Emil Forslund
 * @since 2.0
 */
public interface Meta {

    /**
     * The model that was sent to the generator.
     *
     * @return the model
     */
    A getModel();

    /**
     * The result that was produced by the generator.
     *
     * @return the model
     */
    B getResult();

    /**
     * The transform that was used to produce the result.
     *
     * @return the transform
     */
    Transform getTransform();

    /**
     * The factory that created the transform.
     *
     * @return the factory
     */
    TransformFactory getFactory();

    /**
     * The render stack that represents which generation processes is waiting for this result.
     *
     * @return the current render stack
     */
    RenderStack getRenderStack();
    
    /**
     * Returns a tree representation of the current rendering process.
     * 
     * @return  the rendering tree
     */
    RenderTree getRenderTree();

    /**
     * Returns a new builder.
     *
     * @param  the model type
     * @param  the result type
     * @param model the model
     * @param result the result
     * @return the builder instance.
     */
    static  Meta.Builder builder(A model, B result) {
        return new MetaImpl.Builder<>(model, result);
    }

    /**
     * Builder for {@link Meta} objects.
     * 
     * @param   the model type
     * @param   the result type
     */
    interface Builder {

        /**
         * The model that was sent to the generator.
         *
         * @param model  the model
         * @return       a reference to this builder
         */
        Builder withModel(A model);

        /**
         * The result that was produced by the generator.
         *
         * @param result  the result
         * @return        a reference to this builder
         */
        Builder withResult(B result);

        /**
         * The transform that was used to produce the result.
         *
         * @param transform  the transform
         * @return           a reference to this builder
         */
        Builder withTransform(Transform transform);

        /**
         * The factory that created the transform.
         *
         * @param factory  the factory
         * @return         a reference to this builder
         */
        Builder withFactory(TransformFactory factory);

        /**
         * The render stack that represents which generation processes is waiting for this result.
         *
         * @param stack  the render stack
         * @return       a reference to this builder
         */
        Builder withRenderStack(RenderStack stack);
        
        /**
         * Sets the tree that should represent the current rendering process.
         * 
         * @param tree  the render tree
         * @return      a reference to this builder
         */
        Builder withRenderTree(RenderTree tree);
        
        /**
         * Builds this instance.
         * 
         * @return  the built instance
         */
        Meta build();
    }
}