union method

Returns a PackageVersionNumberGeneralLibraryConstraint that allows PackageVersionNumberGeneralLibrarys allowed by either this or other.

Implementation

@override
PackageVersionNumberGeneralLibraryConstraint union(
    PackageVersionNumberGeneralLibraryConstraint other) {
  if (other.allows(this)) return other;

  if (other is PackageVersionNumberGeneralLibraryRange) {
    if (other.min == this) {
      return PackageVersionNumberGeneralLibraryRange(
          min: other.min,
          max: other.max,
          includeMin: true,
          includeMax: other.includeMax,
          alwaysIncludeMaxPreRelease: true);
    }

    if (other.max == this) {
      return PackageVersionNumberGeneralLibraryRange(
          min: other.min,
          max: other.max,
          includeMin: other.includeMin,
          includeMax: true,
          alwaysIncludeMaxPreRelease: true);
    }
  }

  return PackageVersionNumberGeneralLibraryConstraint.unionOf([this, other]);
}