001// ***** This file is automatically generated from SequencesUnionFactory.java.jpp
002
003package daikon.derive.binary;
004
005import org.checkerframework.checker.nullness.qual.Nullable;
006import org.checkerframework.checker.nullness.qual.Nullable;
007import daikon.*;
008
009// This controls derivations which use the scalar as an index into the
010// sequence, such as getting the element at that index or a subsequence up
011// to that index.
012
013public final class SequenceStringUnionFactory extends BinaryDerivationFactory {
014
015  @Override
016  public BinaryDerivation @Nullable [] instantiate(VarInfo seq1, VarInfo seq2) {
017    if (!SequenceStringUnion.dkconfig_enabled) {
018      return null;
019    }
020
021    if ((seq1.rep_type != ProglangType.STRING_ARRAY) || (seq2.rep_type != ProglangType.STRING_ARRAY)) {
022      return null;
023    }
024
025    // Intersect only sets with the same declared element type
026    if (!seq1.type.base().equals(seq2.type.base())) {
027      return null;
028    }
029
030    // For now, do nothing if the sequences are derived.
031    if ((seq1.derived != null) || (seq2.derived != null)) {
032      return null;
033    }
034
035    return new BinaryDerivation[] {new SequenceStringUnion(seq1, seq2)};
036  }
037}