001    /**
002     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.dynamicdatamapping.storage;
016    
017    /**
018     * @author Marcellus Tavares
019     * @author Eduardo Lundgren
020     */
021    public enum StorageType {
022    
023            EXPANDO("expando"), JSON("json"), XML("xml");
024    
025            public static StorageType parse(String value) {
026                    if (EXPANDO.getValue().equals(value)) {
027                            return EXPANDO;
028                    }
029                    else if (JSON.getValue().equals(value)) {
030                            return JSON;
031                    }
032                    else if (XML.getValue().equals(value)) {
033                            return XML;
034                    }
035                    else {
036                            throw new IllegalArgumentException("Invalid value " + value);
037                    }
038            }
039    
040            public String getValue() {
041                    return _value;
042            }
043    
044            @Override
045            public String toString() {
046                    return _value;
047            }
048    
049            private StorageType(String value) {
050                    _value = value;
051            }
052    
053            private final String _value;
054    
055    }