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

br.com.objectos.rio.GentooPrepareBuilderPojo Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2014 Objectos, Fábrica de 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.rio;

import static com.google.common.collect.Lists.newArrayList;
import static java.lang.String.format;

import java.util.List;

import br.com.objectos.rio.core.InstallCommand;

import br.com.objectos.way.core.io.Directory;

import com.google.common.base.Strings;

/**
 * @author [email protected] (Marcio Endo)
 */
class GentooPrepareBuilderPojo
    implements
    GentooPrepareBuilder,
    GentooPrepareBuilder.TempDirBuilder,
    GentooPrepareBuilder.MountDirBuilder,
    GentooPrepareBuilder.StageServerBuilder,
    GentooPrepareBuilder.DistfilesServerBuilder,
    GentooPrepareBuilder.ResourcesAtBuilder,
    GentooPrepareBuilder.ResourceListAtBuilder,
    GentooPrepareBuilder.ResourceMapAtBuilder,
    GentooPrepareBuilder.ResourceContextBuilder,
    GentooPrepareBuilder.ProfileBuilder,
    GentooPrepareBuilder.KernelVersionBuilder {

  final InstallCommand rioInstall;
  final AbstractRioCommand command;

  private final List chmodList = newArrayList();
  private final List emergeList = newArrayList();
  private final List fetchList = newArrayList();
  private final List mkdirList = newArrayList();
  private final List moveList = newArrayList();
  private final List rcUpdateList = newArrayList();
  private final List realtekList = newArrayList();
  private final List symlinkList = newArrayList();
  private final List useraddList = newArrayList();

  private Directory tempDir;
  private Directory mountDir;
  private HttpServer fileServer;
  private HttpServer distfilesServer;
  private String resourcesAt;
  private String resourcesList;
  private String resourcesMap;
  private Object resourceContext;
  private int profile;
  private String kernelVersion;

  private String pxe;
  private boolean usepkg;

  public GentooPrepareBuilderPojo(InstallCommand rioInstall, AbstractRioCommand command) {
    this.rioInstall = rioInstall;
    this.command = command;
  }

  @Override
  public GentooPrepare build() {
    return new GentooPrepare(this);
  }

  @Override
  public TempDirBuilder tempDirAt(Directory tempDir) {
    this.tempDir = tempDir;
    return this;
  }

  @Override
  public MountDirBuilder mountDirAt(Directory mountDir) {
    this.mountDir = mountDir;
    return this;
  }

  @Override
  public StageServerBuilder stageServer(HttpServer fileServer) {
    this.fileServer = fileServer;
    return this;
  }

  @Override
  public DistfilesServerBuilder distfilesServer(HttpServer distfilesServer) {
    this.distfilesServer = distfilesServer;
    return this;
  }

  @Override
  public ResourcesAtBuilder resourcesAt(String resourcesAt) {
    this.resourcesAt = resourcesAt;
    return this;
  }

  @Override
  public ResourceMapAtBuilder resourcesListAt(String resourcesListAt) {
    this.resourcesList = resourcesListAt;
    return this;
  }

  @Override
  public ResourceListAtBuilder resourcesMapAt(String resourceMapAt) {
    this.resourcesMap = resourceMapAt;
    return this;
  }

  @Override
  public ResourceContextBuilder resourcesContext(Object context) {
    this.resourceContext = context;
    return this;
  }

  @Override
  public ProfileBuilder setProfileTo(int profile) {
    this.profile = profile;
    return this;
  }

  @Override
  public KernelVersionBuilder kernelVersion(String kernelVersion) {
    this.kernelVersion = kernelVersion;
    return this;
  }

  @Override
  public ChmodBuilder chmod() {
    return new GentooPrepareBuilderChmodPojo(this);
  }

  @Override
  public OptionalsBuilder emerge(String atom) {
    this.emergeList.add(new GentooEmerge(atom));
    return this;
  }

  @Override
  public OptionalsBuilder fetch(String distfile) {
    this.fetchList.add(new GentooFetch(distfile));
    return this;
  }

  @Override
  public OptionalsBuilder mkdir(String dir) {
    this.mkdirList.add(new GentooMkdir(dir));
    return this;
  }

  @Override
  public MoveBuilder move(String source) {
    return new GentooPrepareBuilderMovePojo(this, source);
  }

  @Override
  public RcUpdateBuilder rcUpdate() {
    return new GentooPrepareBuilderRcUpdatePojo(this);
  }

  @Override
  public OptionalsBuilder realtek(String tarball) {
    this.realtekList.add(new GentooRealtek(tarball));
    return fetch(format("%s.tar.bz2", tarball));
  }

  @Override
  public SymlinkBuilder symlink(String source) {
    return new GentooPrepareBuilderSymlinkPojo(this, source);
  }

  @Override
  public OptionalsBuilder usepkg() {
    this.usepkg = true;
    return this;
  }

  @Override
  public OptionalsBuilder usepkg(boolean value) {
    this.usepkg = value;
    return this;
  }

  @Override
  public UseraddBuilder useradd() {
    return new GentooPrepareBuilderUseraddPojo(this);
  }

  @Override
  public OptionalsBuilder withPxe(String pxe) {
    this.pxe = pxe;
    return this;
  }

  public Directory getTempDir() {
    return tempDir;
  }

  public Directory getMountDir() {
    return mountDir;
  }

  public HttpServer getFileServer() {
    return fileServer;
  }

  public HttpServer getDistfilesServer() {
    return distfilesServer;
  }

  public String getResourcesAt() {
    return resourcesAt;
  }

  public String getResourcesList() {
    return resourcesList;
  }

  public String getResourcesMap() {
    return resourcesMap;
  }

  public Object getResourceContext() {
    return resourceContext;
  }

  public int getProfile() {
    return profile;
  }

  public String getKernelVersion() {
    return kernelVersion;
  }

  public List getChmodList() {
    return chmodList;
  }

  public List getEmergeList() {
    return emergeList;
  }

  public List getFetchList() {
    return fetchList;
  }

  public List getMkdirList() {
    return mkdirList;
  }

  public List getMoveList() {
    return moveList;
  }

  public List getRcUpdateList() {
    return rcUpdateList;
  }

  public List getRealtekList() {
    return realtekList;
  }

  public List getSymlinkList() {
    return symlinkList;
  }

  public List getUseraddList() {
    return useraddList;
  }

  public boolean isUsepkg() {
    return usepkg;
  }

  public boolean isPxe() {
    return !Strings.isNullOrEmpty(pxe);
  }

  public String getPxe() {
    return Strings.nullToEmpty(pxe);
  }

  void addChmod(GentooChmod chmod) {
    chmodList.add(chmod);
  }

  void addMove(GentooMove move) {
    moveList.add(move);
  }

  void addRcUpdate(GentooRcUpdate rcUpdate) {
    rcUpdateList.add(rcUpdate);
  }

  void addSymlink(GentooSymlink symlink) {
    symlinkList.add(symlink);
  }

  void addUseradd(GentooUseradd useradd) {
    useraddList.add(useradd);
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy