001/* 002 * PlotSquared, a land and world management plugin for Minecraft. 003 * Copyright (C) IntellectualSites <https://intellectualsites.com> 004 * Copyright (C) IntellectualSites team and contributors 005 * 006 * This program is free software: you can redistribute it and/or modify 007 * it under the terms of the GNU General Public License as published by 008 * the Free Software Foundation, either version 3 of the License, or 009 * (at your option) any later version. 010 * 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 * 016 * You should have received a copy of the GNU General Public License 017 * along with this program. If not, see <https://www.gnu.org/licenses/>. 018 */ 019package com.plotsquared.core.uuid; 020 021import org.checkerframework.checker.nullness.qual.NonNull; 022 023import java.util.Objects; 024import java.util.UUID; 025 026/** 027 * A pair consisting of a UUID and a username 028 */ 029public class UUIDMapping { 030 031 private final UUID uuid; 032 private final String username; 033 034 public UUIDMapping(final @NonNull UUID uuid, final @NonNull String username) { 035 this.uuid = uuid; 036 this.username = username; 037 } 038 039 public @NonNull String getUsername() { 040 return this.username; 041 } 042 043 public @NonNull UUID getUuid() { 044 return this.uuid; 045 } 046 047 @Override 048 public boolean equals(final Object o) { 049 if (this == o) { 050 return true; 051 } 052 if (o == null || getClass() != o.getClass()) { 053 return false; 054 } 055 final UUIDMapping that = (UUIDMapping) o; 056 return uuid.equals(that.uuid) && username.equals(that.username); 057 } 058 059 @Override 060 public int hashCode() { 061 return Objects.hash(uuid, username); 062 } 063 064 /** 065 * @deprecated This method is not meant to be invoked or overridden, with no replacement. 066 */ 067 @Deprecated(forRemoval = true, since = "6.6.0") 068 protected boolean canEqual(final Object other) { 069 return other instanceof UUIDMapping; 070 } 071 072}