View Javadoc
1   /*
2    * Copyright 2020-2022 Foreseeti AB <https://foreseeti.com>
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.mal_lang.langspec.builders.step;
18  
19  import java.util.List;
20  import java.util.Map;
21  import org.mal_lang.langspec.Asset;
22  import org.mal_lang.langspec.builders.AssetBuilder;
23  
24  /**
25   * A builder for creating {@link org.mal_lang.langspec.step.StepUnion} objects.
26   *
27   * @since 1.0.0
28   */
29  public final class StepUnionBuilder extends StepBinaryOperationBuilder {
30    /**
31     * Constructs a new {@code StepUnionBuilder} object.
32     *
33     * @param lhs the left-hand side of the union
34     * @param rhs the right-hand side of the union
35     * @throws java.lang.NullPointerException if {@code lhs} or {@code rhs} is {@code null}
36     * @since 1.0.0
37     */
38    public StepUnionBuilder(StepExpressionBuilder lhs, StepExpressionBuilder rhs) {
39      super(lhs, rhs);
40    }
41  
42    @Override
43    public Asset getTarget(
44        Asset sourceAsset, Map<String, Asset> assets, List<AssetBuilder> assetBuilders) {
45      return Asset.leastUpperBound(
46          this.getLhs().getTarget(sourceAsset, assets, assetBuilders),
47          this.getRhs().getTarget(sourceAsset, assets, assetBuilders));
48    }
49  }