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

com.celum.dbtool.step.DbStep Maven / Gradle / Ivy

/*****************************************************************************
 * Copyright 2012 celum Slovakia s r.o.
 *
 * 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.celum.dbtool.step;

import java.io.Reader;

/**
 * Abstraction that representing DB step for inner purposes.
 * There are various implementations of step depends on source.
 * Also step could be SQL or Groovy depends
 * on his {@link StepType type}.
 *
 * @see com.celum.dbtool.resource.DbStepResource
 * @author Zdenko Vrabel ([email protected])
 */
public abstract class DbStep implements Comparable
{
    /** name of step, e.g.: file name etc */
	private final String name;

    /** version of step */
    private final Version version;

    /** step type */
    private final StepType type;


    /**
     * Constructor
     *
     * @param name name of the step (e.g: file name etc)
     */
	public DbStep(String name, Version v, StepType type)
	{
		this.name = name;
        this.version = v;
        this.type = type;
	}


    /**
     * Here you will implement code that returns reader for
     * your step impl.
     *
     * @see StringStep
     * @see FileStep
     *
     * @return step reader
     */
    public abstract Reader getStepReader();


    /**
     * comparing is based on versions all the time.
     * If you want affect the sorting of scripts, change
     * the {@link Version} compare method
     */
    @Override
    public final int compareTo(DbStep script)
    {
        return this.version.compareTo(script.version);
    }


    /**
     * returns step name
     * @return
     */
    public final String getName()
	{
		return name;
	}


    /**
     * returns step version
     * @return
     */
    public final Version getVersion()
    {
        return version;
    }


    /**
     * returns type of step
     * @return
     */
    public StepType getType() {
        return type;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy