001package de.monochromata.anaphors.ast.strategy;
002
003import static de.monochromata.anaphors.ast.reference.strategy.concept.NameRecurrence.Rn_KIND;
004import static de.monochromata.anaphors.ast.relatedexp.strategy.LocalTempVariableContents.REFERENT;
005import static de.monochromata.anaphors.ast.strategy.DA1ReStrategy.DA1Re_KIND;
006
007import de.monochromata.anaphors.ast.ASTBasedAnaphora;
008import de.monochromata.anaphors.ast.AnaphorPart;
009import de.monochromata.anaphors.ast.reference.strategy.concept.NameRecurrence;
010import de.monochromata.anaphors.ast.relatedexp.RelatedExpression;
011import de.monochromata.anaphors.ast.relatedexp.strategy.LocalTempVariableContents;
012import de.monochromata.anaphors.ast.relatedexp.strategy.LocalTempVariableIntroducingStrategy;
013import de.monochromata.anaphors.ast.relatedexp.strategy.RelatedExpressionStrategy;
014
015/**
016 * This is a {@link AnaphorResolutionStrategy} that has a related expression
017 * that is or yields the referent. It uses {@link DA1ReStrategy} and
018 * {@link NameRecurrence} for realization, because this strategy relates to the
019 * referent which is stored in the introduced local temp variable, if such a
020 * variable is introduced (depends on whether the
021 * {@link RelatedExpressionStrategy} is a
022 * {@link LocalTempVariableIntroducingStrategy}).
023 *
024 * @param <N>  The node type in the AST
025 * @param <E>  The expression type
026 * @param <T>  The type type
027 * @param <B>  The binding type
028 * @param <TB> The type binding type
029 * @param <S>  The scope type (optional)
030 * @param <I>  The type used to represent identifiers
031 * @param <QI> The type used to represent qualified identifiers
032 * @param <R>  The sub-type of related expression to use
033 * @param <A>  The sub-type of AST-based anaphora to use
034 */
035public interface StoresReferentInLocalTempVariable<N, E, T, B, TB extends B, S, I, QI, R extends RelatedExpression<N, T, B, TB, S, QI, R>, A extends ASTBasedAnaphora<N, E, T, B, TB, S, I, QI, R, A>>
036                extends AnaphorResolutionStrategy<N, E, T, B, TB, S, I, QI, R, A> {
037
038        @Override
039        default LocalTempVariableContents getLocalTempVariableContents() {
040                return REFERENT;
041        }
042
043        @Override
044        default String getKindOfAnaphorResolutionStrategyToBeRealized(
045                        final AnaphorPart<N, E, T, B, TB, S, I, QI, R, A> anaphorPart) {
046                return DA1Re_KIND;
047        }
048
049        /**
050         * Always returns {@link NameRecurrence#Rn_KIND} because re-resolution triggered
051         * after realization will always be name-based as it is based on the name of the
052         * local variable that was introduced to store the referent.
053         */
054        @Override
055        default String getKindOfReferentializationStrategyToBeRealized(
056                        final AnaphorPart<N, E, T, B, TB, S, I, QI, R, A> anaphorPart) {
057                return Rn_KIND;
058        }
059
060}