org.mayocat.model.AddonFieldType.java Source code

Java tutorial

Introduction

Here is the source code for org.mayocat.model.AddonFieldType.java

Source

/*
 * Copyright (c) 2012, Mayocat <hello@mayocat.org>
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */
package org.mayocat.model;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @version $Id: 2a8d142a0a4567e7134087ef04b1a69e2e30689e $
 */
public enum AddonFieldType {

    STRING, HTML, JSON;

    @JsonValue
    public String toJson() {
        return name().toLowerCase();
    }

    @JsonCreator
    public static AddonFieldType fromJson(String text) {
        if (text == null) {
            return null;
        }
        return valueOf(text.toUpperCase());
    }
}