
org.nuiton.topia.service.migration.resources.MigrationVersionResource Maven / Gradle / Ivy
Show all versions of topia-extension-migration Show documentation
package org.nuiton.topia.service.migration.resources;
/*-
* #%L
* ObServe Toolkit :: ToPIA Migration service
* %%
* Copyright (C) 2017 - 2018 IRD, Ultreia.io
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* .
* #L%
*/
import org.nuiton.version.Version;
import java.io.IOException;
import java.util.Objects;
/**
* This is the class to override for each migration version.
*
* Just implements the {@link #generateSqlScript(MigrationVersionResourceExecutor)} method and make available this class
* to {@link java.util.ServiceLoader} mechanism.
*
* Created by tchemit on 05/05/2018.
*
* @author Tony Chemit - [email protected]
*/
public abstract class MigrationVersionResource {
private final Version version;
public MigrationVersionResource(Version version) {
this.version = Objects.requireNonNull(version);
}
public abstract void generateSqlScript(MigrationVersionResourceExecutor executor) throws IOException;
public Version getVersion() {
return version;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MigrationVersionResource that = (MigrationVersionResource) o;
return Objects.equals(version, that.version);
}
@Override
public int hashCode() {
return Objects.hash(version);
}
}