001/*
002 * (C) Copyright 2006-20012 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Nuxeo - initial API and implementation
016 *
017 */
018
019package org.nuxeo.template.api;
020
021import java.util.EnumSet;
022import java.util.Date;
023
024/**
025 * Enum for types of {@link TemplateInput}
026 *
027 * @author <a href="mailto:td@nuxeo.com">Thierry Delprat</a>
028 */
029public enum InputType {
030
031    StringValue(String.class.getSimpleName()), BooleanValue(Boolean.class.getSimpleName()), DateValue(
032            Date.class.getSimpleName()), DocumentProperty("source"), PictureProperty("picture"), Content("content");
033
034    private final String value;
035
036    InputType(String value) {
037        this.value = value;
038    }
039
040    public String getValue() {
041        return value;
042    }
043
044    @Override
045    public String toString() {
046        return value;
047    }
048
049    public static InputType getByValue(String value) {
050        InputType returnValue = null;
051        for (final InputType element : EnumSet.allOf(InputType.class)) {
052            if (element.toString().equals(value)) {
053                returnValue = element;
054            }
055        }
056        return returnValue;
057    }
058}