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.ratings;
016    
017    /**
018     * @author Sergio Gonzalez
019     * @author Roberto D??az
020     */
021    public enum RatingsType {
022    
023            LIKE("like"), STARS("stars"), THUMBS("thumbs");
024    
025            public static RatingsType parse(String value) {
026                    if (LIKE.getValue().equals(value)) {
027                            return LIKE;
028                    }
029                    else if (STARS.getValue().equals(value)) {
030                            return STARS;
031                    }
032                    else if (THUMBS.getValue().equals(value)) {
033                            return THUMBS;
034                    }
035    
036                    throw new IllegalArgumentException("Invalid value " + value);
037            }
038    
039            public String getValue() {
040                    return _value;
041            }
042    
043            @Override
044            public String toString() {
045                    return _value;
046            }
047    
048            private RatingsType(String value) {
049                    _value = value;
050            }
051    
052            private final String _value;
053    
054    }