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.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (c) 2006-2013 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. * @author chris
  27. * @since 0.6.4
  28. */
  29. public class ChannelJoinRequest {
  30. /** The name of the channel to join (required). */
  31. private final String name;
  32. /** The name of the password to use (optional). */
  33. private final String password;
  34. /**
  35. * Creates a new ChannelJoinRequest for a password-less channel with
  36. * the specified name.
  37. *
  38. * @param name The name of the channel to join
  39. */
  40. public ChannelJoinRequest(final String name) {
  41. this(name, null);
  42. }
  43. /**
  44. * Creates a new ChannelJoinRequest for a channel with the specified
  45. * password.
  46. *
  47. * @param name The name of the channel to join
  48. * @param password The password to use
  49. */
  50. public ChannelJoinRequest(final String name, final String password) {
  51. this.name = name;
  52. this.password = password;
  53. }
  54. /**
  55. * Retrieves the name of the channel this request will try to join.
  56. *
  57. * @return The name of the channel in this request
  58. */
  59. public String getName() {
  60. return name;
  61. }
  62. /**
  63. * Retrieves the password which will be used to try to join the channel.
  64. *
  65. * @return The password to use, or null if none specified
  66. */
  67. public String getPassword() {
  68. return password;
  69. }
  70. /** {@inheritDoc} */
  71. @Override
  72. public boolean equals(final Object obj) {
  73. return obj instanceof ChannelJoinRequest
  74. && ((ChannelJoinRequest) obj).getName().equals(name)
  75. && ((((ChannelJoinRequest) obj).getPassword() == null
  76. ? password == null : ((ChannelJoinRequest) obj).getPassword().equals(password)));
  77. }
  78. /** {@inheritDoc} */
  79. @Override
  80. public int hashCode() {
  81. int hash = name != null ? name.hashCode() : 0;
  82. hash = 13 * hash + (password != null ? password.hashCode() : 0);
  83. return hash;
  84. }
  85. }