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

com.intellij.util.io.TestFileSystemBuilder Maven / Gradle / Ivy

Go to download

A packaging of the IntelliJ Community Edition testFramework library. This is release number 1 of trunk branch 142.

The newest version!
package com.intellij.util.io;

import org.jetbrains.annotations.NotNull;

/**
 * @author nik
 */
public class TestFileSystemBuilder {
  private final TestFileSystemItem myItem;
  private final TestFileSystemBuilder myParent;

  private TestFileSystemBuilder(TestFileSystemItem item, TestFileSystemBuilder parent) {
    myItem = item;
    myParent = parent;
  }

  @NotNull
  public TestFileSystemItem build() {
    TestFileSystemBuilder builder = this;
    while (builder.myParent != null) {
      builder = builder.myParent;
    }
    return builder.myItem;
  }

  @NotNull
  public TestFileSystemBuilder dir(String name) {
    final TestFileSystemItem item = new TestFileSystemItem(name, false, true);
    myItem.addChild(item);
    return new TestFileSystemBuilder(item, this);
  }

  @NotNull
  public TestFileSystemBuilder archive(String name) {
    final TestFileSystemItem item = new TestFileSystemItem(name, true, false);
    myItem.addChild(item);
    return new TestFileSystemBuilder(item, this);
  }

  @NotNull
  public TestFileSystemBuilder file(String name) {
    myItem.addChild(new TestFileSystemItem(name, false, false));
    return this;
  }

  @NotNull
  public TestFileSystemBuilder file(String name, String content) {
    myItem.addChild(new TestFileSystemItem(name, false, false, content));
    return this;
  }

  public TestFileSystemBuilder end() {
    return myParent;
  }

  @NotNull
  public static TestFileSystemBuilder fs() {
    return new TestFileSystemBuilder(new TestFileSystemItem("root", false, true), null);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy