<commit_before>package mytown.entities;

import java.util.ArrayList;

import mytown.entities.town.Town;
import net.minecraft.util.EnumChatFormatting;

public class Rank {

	private String key;
	private String name;
	private ArrayList<String> permissions; // Lists > Arrays
	private Town town;

	/**
	 * Constructor for Rank
	 * 
	 * @param name
	 * @param permissions
	 * @param town
	 *            null only if it's a default rank
	 */
	public Rank(String name, ArrayList<String> permissions, Town town) {
		this.name = name;
		this.permissions = permissions;
		this.town = town;
		updateKey();
	}

	public boolean addPermission(String perm) {
		if (hasPermission(perm))
			return false;
		return permissions.add(perm);
	}

	public boolean removePermission(String perm) {
		return permissions.remove(perm);
	}

	/**
	 * Gets the name of the Rank
	 * 
	 * @return
	 */
	public String getName() {
		return name;
	}

	/**
	 * Gets all the permission of the Rank
	 * 
	 * @return
	 */
	public ArrayList<String> getPermissions() {
		return permissions;
	}

	/**
	 * Gets all permissions in one long String with format "permission permission perm..." Used for saving into Database
	 * 
	 * @return
	 */

	public String getPermissionsWithFormat() {
		String temp = null;
		for (String s : permissions)
			if (temp == null) {
				temp = s;
			} else {
				temp += " " + s;
			}
		return temp;
	}

	/**
	 * 
	 * Gets the key of this rank
	 * 
	 * @return
	 */
	public String getKey() {
		return key;
	}

	/**
	 * Updates the key. Only called in the constructor and when updating in the database. DO NOT CALL ELSEWHERE!
	 * 
	 * @return
	 */
	public void updateKey() {
		key = String.format("%s;%s", town.getName(), name);
	}

	/**
	 * Gets the Town in which this Rank is found
	 * 
	 * @return
	 */
	public Town getTown() {
		return town;
	}

	/**
	 * Checks if the given perm String matches any this Rank has
	 * 
	 * @param perm
	 * @return
	 */
	public boolean hasPermission(String perm) {
		if (permissions == null)
			return false;
		for (String p : permissions) {
			if (p.equals(perm))
				return true;
		}
		return false;
	}

	@Override
	public String toString() {
		return EnumChatFormatting.GREEN + name;
	}
}<commit_msg>A little code cleanup and modifications.<commit_after>package mytown.entities;

import java.util.ArrayList;

import com.google.common.base.Joiner;

import mytown.entities.town.Town;
import net.minecraft.util.EnumChatFormatting;

public class Rank {

	private String key;
	private String name;
	private ArrayList<String> permissions; // Lists > Arrays
	private Town town;

	/**
	 * Constructor for Rank
	 * 
	 * @param name
	 * @param permissions
	 * @param town
	 *            null only if it's a default rank
	 */
	public Rank(String name, ArrayList<String> permissions, Town town) {
		this.name = name;
		this.permissions = permissions;
		this.town = town;
		updateKey();
	}

	public boolean addPermission(String perm) {
		if (hasPermission(perm))
			return false;
		return permissions.add(perm);
	}

	public boolean removePermission(String perm) {
		return permissions.remove(perm);
	}

	/**
	 * Gets the name of the Rank
	 * 
	 * @return
	 */
	public String getName() {
		return name;
	}

	/**
	 * Gets all the permission of the Rank
	 * 
	 * @return
	 */
	public ArrayList<String> getPermissions() {
		return permissions;
	}

	/**
	 * Gets all permissions in one long String with format "permission permission perm..." Used for saving into Database
	 * 
	 * @return
	 */
	public String getPermissionsWithFormat() {
		return Joiner.on(" ").join(permissions);
	}

	/**
	 * 
	 * Gets the key of this rank
	 * 
	 * @return
	 */
	public String getKey() {
		return key;
	}

	/**
	 * Updates the key. Only called in the constructor and when updating in the database. DO NOT CALL ELSEWHERE!
	 * 
	 * @return
	 */
	public void updateKey() {
		key = String.format("%s;%s", town.getName(), name);
	}

	/**
	 * Gets the Town in which this Rank is found
	 * 
	 * @return
	 */
	public Town getTown() {
		return town;
	}

	/**
	 * Checks if the given perm String matches any this Rank has
	 * 
	 * @param perm
	 * @return
	 */
	public boolean hasPermission(String perm) {
		if (permissions == null)
			return false;
		return permissions.contains(perm);
	}

	@Override
	public String toString() {
		return EnumChatFormatting.GREEN + name;
	}
}
{'fraction_non_alphanumeric': 0.11274397244546498, 'fraction_numerical': 0.0, 'mean_word_length': 2.9817184643510055, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '361971', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1308, 'n_words': 439}