コード例 #1
0
ファイル: Specification.java プロジェクト: saeg/experiments
 /**
  * Test if two specifications are equal except for their sections.
  *
  * @param specification one specificaiton
  * @param other the ohter specification
  * @return true if two specifications are equal except for their sections, else false
  */
 private static boolean isEqual(final Specification specification, final Specification other) {
   return specification.getSpecificationTitle().equals(other.getSpecificationTitle())
       && specification.getSpecificationVersion().isEqual(other.getSpecificationVersion())
       && specification.getSpecificationVendor().equals(other.getSpecificationVendor())
       && specification.getImplementationTitle().equals(other.getImplementationTitle())
       && specification.getImplementationVersion().equals(other.getImplementationVersion())
       && specification.getImplementationVendor().equals(other.getImplementationVendor());
 }
コード例 #2
0
ファイル: Specification.java プロジェクト: saeg/experiments
  /**
   * Return a Compatibility enum indicating the relationship of this <code>Package Specification
   * </code> with the specified <code>Extension</code>.
   *
   * @param other the other specification
   * @return the enum indicating the compatibility (or lack thereof) of specifed Package
   *     Specification
   */
  public Compatibility getCompatibilityWith(final Specification other) {
    // Specification Name must match
    if (!m_specificationTitle.equals(other.getSpecificationTitle())) {
      return INCOMPATIBLE;
    }

    // Available specification version must be >= required
    final DeweyDecimal specificationVersion = other.getSpecificationVersion();
    if (null != specificationVersion) {
      if (null == m_specificationVersion
          || !isCompatible(m_specificationVersion, specificationVersion)) {
        return REQUIRE_SPECIFICATION_UPGRADE;
      }
    }

    // Implementation Vendor ID must match
    final String implementationVendor = other.getImplementationVendor();
    if (null != implementationVendor) {
      if (null == m_implementationVendor || !m_implementationVendor.equals(implementationVendor)) {
        return REQUIRE_VENDOR_SWITCH;
      }
    }

    // Implementation version must be >= required
    final String implementationVersion = other.getImplementationVersion();
    if (null != implementationVersion) {
      if (null == m_implementationVersion
          || !m_implementationVersion.equals(implementationVersion)) {
        return REQUIRE_IMPLEMENTATION_CHANGE;
      }
    }

    // This available optional package satisfies the requirements
    return COMPATIBLE;
  }
コード例 #3
0
ファイル: Specification.java プロジェクト: saeg/experiments
  /**
   * Merge the specified sections into specified section and return result. If no sections to be
   * added then just return original specification.
   *
   * @param specification the specification
   * @param sectionsToAdd the list of sections to merge
   * @return the merged specification
   */
  private static Specification mergeInSections(
      final Specification specification, final ArrayList sectionsToAdd) {
    if (0 == sectionsToAdd.size()) {
      return specification;
    } else {
      sectionsToAdd.addAll(Arrays.asList(specification.getSections()));

      final String[] sections = (String[]) sectionsToAdd.toArray(new String[sectionsToAdd.size()]);

      return new Specification(
          specification.getSpecificationTitle(),
          specification.getSpecificationVersion().toString(),
          specification.getSpecificationVendor(),
          specification.getImplementationTitle(),
          specification.getImplementationVersion(),
          specification.getImplementationVendor(),
          sections);
    }
  }