예제 #1
0
  /**
   * retrieves the data from the given Capabilities object
   *
   * @param c the capabilities object to initialize with
   */
  public void assign(Capabilities c) {
    for (Capability cap : Capability.values()) {
      // capability
      if (c.handles(cap)) enable(cap);
      else disable(cap);
      // dependency
      if (c.hasDependency(cap)) enableDependency(cap);
      else disableDependency(cap);
    }

    setMinimumNumberInstances(c.getMinimumNumberInstances());
  }
예제 #2
0
  /**
   * performs an OR conjunction with the capabilities of the given Capabilities object and updates
   * itself
   *
   * @param c the capabilities to OR with
   */
  public void or(Capabilities c) {
    for (Capability cap : Capability.values()) {
      // capability
      if (handles(cap) || c.handles(cap)) m_Capabilities.add(cap);
      else m_Capabilities.remove(cap);
      // dependency
      if (hasDependency(cap) || c.hasDependency(cap)) m_Dependencies.add(cap);
      else m_Dependencies.remove(cap);
    }

    if (c.getMinimumNumberInstances() < getMinimumNumberInstances())
      setMinimumNumberInstances(c.getMinimumNumberInstances());
  }
예제 #3
0
  /**
   * performs an AND conjunction with the capabilities of the given Capabilities object and updates
   * itself
   *
   * @param c the capabilities to AND with
   */
  public void and(Capabilities c) {
    for (Capability cap : Capability.values()) {
      // capability
      if (handles(cap) && c.handles(cap)) m_Capabilities.add(cap);
      else m_Capabilities.remove(cap);
      // dependency
      if (hasDependency(cap) && c.hasDependency(cap)) m_Dependencies.add(cap);
      else m_Dependencies.remove(cap);
    }

    // minimum number of instances that both handlers need at least to work
    if (c.getMinimumNumberInstances() > getMinimumNumberInstances())
      setMinimumNumberInstances(c.getMinimumNumberInstances());
  }