### File

`src/factory/question-factory.ts`

### Index

###### Methods
Public createQuestion Public createQuestionList

### Methods

Public createQuestion
`createQuestion(question: Question)`
Defined in src/factory/question-factory.ts:5
Parameters :
Name | Type | Optional | Description
question | `Question<any>` |  |
Returns : `Question<any>`

Public createQuestionList
`createQuestionList(questionList: Question[])`
Defined in src/factory/question-factory.ts:20
Parameters :
Name | Type | Optional | Description
questionList | `Question[]` |  |
Returns : `[]`

    import { Question, QuestionType, Text, TextArea, Checkbox, Radio, Select } from '../question';

    export class QuestionFactory {

      public static createQuestion(question: Question<any>): Question<any> {
        switch (question.type) {
          case QuestionType.CHECKBOX:
            return Checkbox.fromJson(<Checkbox>question);
          case QuestionType.RADIO:
            return Radio.fromJson(<Radio>question);
          case QuestionType.SELECT:
            return Select.fromJson(<Select>question);
          case QuestionType.TEXTAREA:
            return TextArea.fromJson(<TextArea>question);
          default:
            return Text.fromJson(<Text>question);
        }
      }

      public static createQuestionList(questionList: Question<any>[]): Question<any>[] {
        return questionList.map((question: Question<any>) => QuestionFactory.createQuestion(question));
      }
    }

# results matching ""

# No results matching ""