All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.fulib.scenarios.visitor.GetAnswerSentence Maven / Gradle / Ivy

package org.fulib.scenarios.visitor;

import org.fulib.scenarios.ast.sentence.*;

import java.util.List;

public enum GetAnswerSentence implements Sentence.Visitor
{
   INSTANCE;

   @Override
   public AnswerSentence visit(Sentence sentence, Object par)
   {
      return null;
   }

   @Override
   public AnswerSentence visit(SentenceList sentenceList, Object par)
   {
      final List items = sentenceList.getItems();
      return items.isEmpty() ? null : items.get(items.size() - 1).accept(this, par);
   }

   @Override
   public AnswerSentence visit(AnswerSentence answerSentence, Object par)
   {
      return answerSentence;
   }

   @Override
   public AnswerSentence visit(ConditionalSentence conditionalSentence, Object par)
   {
      return conditionalSentence.getBody().accept(this, par);
   }

   @Override
   public AnswerSentence visit(TakeSentence takeSentence, Object par)
   {
      return takeSentence.getBody().accept(this, par);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy