You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ChannelJoinRequest.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * Copyright (c) 2006-2017 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.parser.common;
  23. /**
  24. * Describes the information needed to try and join a channel.
  25. */
  26. public class ChannelJoinRequest {
  27. /** The name of the channel to join (required). */
  28. private final String name;
  29. /** The name of the password to use (optional). */
  30. private final String password;
  31. /**
  32. * Creates a new ChannelJoinRequest for a password-less channel with
  33. * the specified name.
  34. *
  35. * @param name The name of the channel to join
  36. */
  37. public ChannelJoinRequest(final String name) {
  38. this(name, null);
  39. }
  40. /**
  41. * Creates a new ChannelJoinRequest for a channel with the specified
  42. * password.
  43. *
  44. * @param name The name of the channel to join
  45. * @param password The password to use
  46. */
  47. public ChannelJoinRequest(final String name, final String password) {
  48. this.name = name;
  49. this.password = password;
  50. }
  51. /**
  52. * Retrieves the name of the channel this request will try to join.
  53. *
  54. * @return The name of the channel in this request
  55. */
  56. public String getName() {
  57. return name;
  58. }
  59. /**
  60. * Retrieves the password which will be used to try to join the channel.
  61. *
  62. * @return The password to use, or null if none specified
  63. */
  64. public String getPassword() {
  65. return password;
  66. }
  67. @Override
  68. public boolean equals(final Object obj) {
  69. return obj instanceof ChannelJoinRequest
  70. && ((ChannelJoinRequest) obj).getName().equals(name)
  71. && ((((ChannelJoinRequest) obj).getPassword() == null
  72. ? password == null : ((ChannelJoinRequest) obj).getPassword().equals(password)));
  73. }
  74. @Override
  75. public int hashCode() {
  76. int hash = name != null ? name.hashCode() : 0;
  77. hash = 13 * hash + (password != null ? password.hashCode() : 0);
  78. return hash;
  79. }
  80. }