br.com.objectos.git.GitServiceBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of objectos-git Show documentation
Show all versions of objectos-git Show documentation
ObjectosGit is a pure Java library that provides a limited set of GIT operations.
The newest version!
/*
* Copyright (C) 2020-2022 Objectos Software LTDA.
*
* 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 br.com.objectos.git;
import br.com.objectos.concurrent.CpuArray;
import br.com.objectos.concurrent.CpuWorker;
import br.com.objectos.concurrent.IoWorker;
import br.com.objectos.core.object.Checks;
import br.com.objectos.logging.Logger;
import br.com.objectos.logging.NoopLogger;
/**
* @since 3
*/
final class GitServiceBuilder {
private int bufferSize = Git.DEFAULT_BUFFER_SIZE;
private final CpuArray cpuArray;
private int enginesPerWorker = 1;
private final IoWorker ioWorker;
private Logger logger = NoopLogger.getInstance();
GitServiceBuilder(CpuArray cpuArray, IoWorker ioWorker) {
this.cpuArray = Checks.checkNotNull(cpuArray, "cpuArray == null");
this.ioWorker = Checks.checkNotNull(ioWorker, "ioWorker == null");
}
public final GitService build() {
int arraySize;
arraySize = cpuArray.size();
GitWorker[] workers;
workers = new GitWorker[arraySize];
GitEngine.Option[] engineOptions = {
GitEngine.bufferSize(bufferSize),
GitEngine.logger(logger)
};
for (int i = 0; i < arraySize; i++) {
CpuWorker cpuWorker;
cpuWorker = cpuArray.get(i);
workers[i] = GitWorker.create(cpuWorker, ioWorker, enginesPerWorker, engineOptions);
}
return new GitService(cpuArray, workers);
}
final void setBufferSize(int size) {
this.bufferSize = size;
}
final void setEnginesPerWorker(int value) {
enginesPerWorker = value;
}
final void setLogger(Logger logger) {
this.logger = logger;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy