001package com.github.theholywaffle.teamspeak3.api.wrapper; 002 003/* 004 * #%L 005 * TeamSpeak 3 Java API 006 * %% 007 * Copyright (C) 2014 Bert De Geyter 008 * %% 009 * Permission is hereby granted, free of charge, to any person obtaining a copy 010 * of this software and associated documentation files (the "Software"), to deal 011 * in the Software without restriction, including without limitation the rights 012 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 013 * copies of the Software, and to permit persons to whom the Software is 014 * furnished to do so, subject to the following conditions: 015 * 016 * The above copyright notice and this permission notice shall be included in 017 * all copies or substantial portions of the Software. 018 * 019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 020 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 021 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 022 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 023 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 024 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 025 * THE SOFTWARE. 026 * #L% 027 */ 028 029import java.util.Map; 030 031/** 032 * Describes a permission that has been assigned to a client, 033 * a channel group or a server group. 034 * <p> 035 * For a complete description of the TS3 permission system, refer to 036 * <a href="http://forum.teamspeak.com/threads/49581-The-New-Permission-Documentataions"> 037 * this post</a> on the TeamSpeak forums. 038 * </p> 039 */ 040public class Permission extends Wrapper { 041 042 public Permission(Map<String, String> map) { 043 super(map); 044 } 045 046 /** 047 * Gets the name of this permission. 048 * <p> 049 * Boolean permissions are prefixed with {@code b_}<br> 050 * Integer permissions are prefixed with {@code i_} 051 * </p> 052 * 053 * @return this permission's name 054 */ 055 public String getName() { 056 return get("permsid"); 057 } 058 059 /** 060 * Gets the value of this permission assignment. 061 * <p> 062 * Please note that this value doesn't necessarily have to be 063 * the effective permission value for a client, as this assignment 064 * can be overridden by another assignment. 065 * </p><p> 066 * Integer permissions usually have values between 0 and 100, 067 * but any integer value is theoretically valid. 068 * </p><p> 069 * Boolean permissions have a value of {@code 0} to represent 070 * {@code false} and {@code 1} to represent {@code true}. 071 * </p> 072 * 073 * @return the value of this permission assignment 074 */ 075 public int getValue() { 076 return getInt("permvalue"); 077 } 078 079 /** 080 * Returns {@code true} if this permission is negated. 081 * <p> 082 * Negated means that instead of the highest value, the lowest 083 * value will be selected for this permission instead. 084 * </p> 085 * 086 * @return whether this permission is negated or not 087 */ 088 public boolean isNegated() { 089 return getBoolean("permnegated"); 090 } 091 092 /** 093 * Returns {@code true} if this permission is skipped. 094 * <p> 095 * Skipped only exists for server group and client permissions, 096 * therefore this value will always be false for channel group permissions. 097 * </p><p> 098 * If a client permission is skipped, it won't be overridden by channel 099 * group permissions.<br> 100 * If a server group permission is skipped, it won't be overridden by 101 * channel group or client permissions. 102 * </p> 103 * 104 * @return whether this permission is negated or not 105 */ 106 public boolean isSkipped() { 107 return getBoolean("permskip"); 108 } 109 110}