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.social.util;
016    
017    /**
018     * @author Adolfo P??rez
019     * @author Sergio Gonz??lez
020     */
021    public class SocialInteractionsConfiguration {
022    
023            public SocialInteractionsConfiguration(
024                    boolean socialInteractionsFriendsEnabled,
025                    boolean socialInteractionsSitesEnabled,
026                    SocialInteractionsType socialInteractionsType) {
027    
028                    _socialInteractionsFriendsEnabled = socialInteractionsFriendsEnabled;
029                    _socialInteractionsSitesEnabled = socialInteractionsSitesEnabled;
030                    _socialInteractionsType = socialInteractionsType;
031            }
032    
033            public boolean isSocialInteractionsAnyUserEnabled() {
034                    if (_socialInteractionsType.equals(SocialInteractionsType.ALL_USERS)) {
035                            return true;
036                    }
037                    else {
038                            return false;
039                    }
040            }
041    
042            public boolean isSocialInteractionsFriendsEnabled() {
043                    return _socialInteractionsFriendsEnabled;
044            }
045    
046            public boolean isSocialInteractionsSelectUsersEnabled() {
047                    if (_socialInteractionsType.equals(
048                                    SocialInteractionsType.SELECT_USERS)) {
049    
050                            return true;
051                    }
052                    else {
053                            return false;
054                    }
055            }
056    
057            public boolean isSocialInteractionsSitesEnabled() {
058                    return _socialInteractionsSitesEnabled;
059            }
060    
061            public enum SocialInteractionsType {
062    
063                    ALL_USERS("all_users"), SELECT_USERS("select_users");
064    
065                    public static SocialInteractionsType parse(String value) {
066                            if (ALL_USERS.getValue().equals(value)) {
067                                    return ALL_USERS;
068                            }
069                            else if (SELECT_USERS.getValue().equals(value)) {
070                                    return SELECT_USERS;
071                            }
072    
073                            throw new IllegalArgumentException("Invalid value " + value);
074                    }
075    
076                    public String getValue() {
077                            return _value;
078                    }
079    
080                    @Override
081                    public String toString() {
082                            return _value;
083                    }
084    
085                    private SocialInteractionsType(String value) {
086                            _value = value;
087                    }
088    
089                    private final String _value;
090    
091            }
092    
093            private final boolean _socialInteractionsFriendsEnabled;
094            private final boolean _socialInteractionsSitesEnabled;
095            private final SocialInteractionsType _socialInteractionsType;
096    
097    }