travel.izi.api.model.entity.Quiz Maven / Gradle / Ivy
/*
* Copyright (C) 2014 IZITEQ B.V.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package travel.izi.api.model.entity;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import com.google.auto.value.AutoValue;
import travel.izi.api.model.enumeration.QuizType;
import javax.annotation.Nullable;
import java.io.Serializable;
import java.util.List;
/**
* The quiz.
*/
@SuppressWarnings("unused")
@AutoValue
@JsonDeserialize(builder = AutoValue_Quiz.Builder.class)
public abstract class Quiz implements Serializable {
/**
* The answer to the quiz.
*/
@AutoValue
@JsonDeserialize(builder = AutoValue_Quiz_Answer.Builder.class)
public abstract static class Answer implements Serializable {
public static Builder builder() {
return new AutoValue_Quiz_Answer.Builder();
}
/**
* The answer's content.
*/
public abstract String content();
/**
* Mark of correctness.
*/
public abstract Boolean correct();
@AutoValue.Builder
@JsonPOJOBuilder(withPrefix = "")
public abstract static class Builder {
public abstract Builder content(String content);
public abstract Builder correct(Boolean correct);
public abstract Answer build();
}
}
public static Builder builder() {
return new AutoValue_Quiz.Builder();
}
/**
* Type of quiz.
*/
// TODO: Make mandatory as from 1.3 version
@Nullable
public abstract QuizType type();
/**
* Quiz's question.
*/
public abstract String question();
/**
* The comment for a correct answer.
*/
@Nullable
public abstract String comment();
/**
* Array of answers. The correct answer is marked.
*/
public abstract List answers();
@AutoValue.Builder
@JsonPOJOBuilder(withPrefix = "")
public abstract static class Builder {
public abstract Builder type(QuizType type);
public abstract Builder question(String question);
public abstract Builder comment(String comment);
public abstract Builder answers(List answers);
public abstract Quiz build();
}
}