/**
  * @return the delegate bound to this decorator. Never a <code>null</code> reference.
  * @throws IllegalArgumentException if the delegate returned by {@link #createDelegate()} is
  *     <code>null</code> or the same reference as this decorator class
  */
 protected final UISelectMany<VALUETYPE> getDelegate() {
   if (delegate == null) {
     delegate = createDelegate();
     Assert.notNull(delegate, "Delegate cannot be null");
     Assert.isTrue(delegate != this, "Decorator cannot delegate to itself");
   }
   return delegate;
 }
  /** Create a new {@link AddonDependencyEntry} with the given attributes. */
  public static AddonDependencyEntry create(
      String name, VersionRange range, boolean exported, boolean optional) {
    Assert.notNull(name, "Addon name must not be null.");
    Assert.notNull(range, "Addon version must not be null.");

    AddonDependencyEntry entry = new AddonDependencyEntry();
    entry.name = name;
    entry.version = range;
    entry.exported = exported;
    entry.optional = optional;
    return entry;
  }
Beispiel #3
0
  public static boolean delete(File file, final boolean recursive) {
    Assert.notNull(file, "File to delete must not be null.");

    boolean result = false;
    if (recursive) {
      result = _deleteRecursive(file, true);
    } else {
      if ((file.listFiles() != null) && (file.listFiles().length != 0)) {
        throw new RuntimeException("directory not empty");
      }

      if (OperatingSystemUtils.isWindows()) {
        System.gc(); // ensure no lingering handles that would prevent deletion
      }

      result = file.delete();
    }
    return result;
  }
Beispiel #4
0
  private static boolean _deleteRecursive(final File file, final boolean collect) {
    Assert.notNull(file, "File to delete must not be null.");

    boolean result = true;
    if (collect && OperatingSystemUtils.isWindows()) {
      System.gc(); // ensure no lingering handles that would prevent deletion
    }

    File[] children = file.listFiles();
    if (children != null) {
      for (File sf : children) {
        if (sf.isDirectory()) {
          if (!_deleteRecursive(sf, false)) result = false;
        } else {
          if (!sf.delete()) result = false;
        }
      }
    }

    return file.delete() && result;
  }
Beispiel #5
0
 /**
  * Requests that the file or directory denoted by this resource be deleted when the virtual
  * machine terminates.
  *
  * <p>Once deletion has been requested, it is not possible to cancel the request. This method
  * should therefore be used with care.
  */
 public static void deleteOnExit(File file) {
   Assert.notNull(file, "File to delete must not be null.");
   file.deleteOnExit();
 }
Beispiel #6
0
 public static boolean delete(File file) {
   Assert.notNull(file, "File to delete must not be null.");
   return delete(file, false);
 }
Beispiel #7
0
 /** Optionally specify the variable name to use for the output of this condition */
 @Override
 public ConditionBuilder as(String variable) {
   Assert.notNull(variable, "Variable name must not be null.");
   this.setOutputVariablesName(variable);
   return this;
 }