com.speedment.generator.core.translator.AbstractTranslatorManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tool-deploy Show documentation
Show all versions of tool-deploy Show documentation
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.generator.core.translator;
import com.speedment.common.codegen.Meta;
import com.speedment.common.codegen.model.File;
import com.speedment.common.injector.Injector;
import com.speedment.common.injector.State;
import com.speedment.common.injector.annotation.ExecuteBefore;
import com.speedment.generator.core.internal.translator.TranslatorManagerHelper;
import com.speedment.generator.translator.TranslatorManager;
import com.speedment.runtime.config.Project;
import java.nio.file.Path;
/**
* Abstract base implementation for different translator managers.
*
* @author Emil Forslund
* @since 3.0.2
*/
public abstract class AbstractTranslatorManager implements TranslatorManager {
private final TranslatorManagerHelper helper;
protected AbstractTranslatorManager() {
helper = new TranslatorManagerHelper();
}
@ExecuteBefore(State.INITIALIZED)
void init(Injector injector) {
// Since we created the instance of 'helper' manually, we have to
// invoke the injector manually. We can do this in the "INITIALIZED"
// phase since we don't need access to any components and we want to
// simulate that this happends on construction.
injector.inject(helper);
}
@Override
public void accept(Project project) {
helper.accept(this, project);
}
@Override
public void clearExistingFiles(Project project) {
helper.clearExistingFiles(project);
}
@Override
public void writeToFile(Project project, Meta meta, boolean overwriteExisting) {
helper.writeToFile(this, project, meta, overwriteExisting);
}
@Override
public void writeToFile(Project project, String filename, String content, boolean overwriteExisting) {
helper.writeToFile(this, project, filename, content, overwriteExisting);
}
@Override
public void writeToFile(Path location, String content, boolean overwriteExisting) {
helper.writeToFile(this, location, content, overwriteExisting);
}
@Override
public int getFilesCreated() {
return helper.getFilesCreated();
}
}