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.

BaseChannelClientInfo.java 2.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. import com.dmdirc.parser.interfaces.ChannelClientInfo;
  24. import com.dmdirc.parser.interfaces.ChannelInfo;
  25. import com.dmdirc.parser.interfaces.ClientInfo;
  26. import java.util.HashMap;
  27. import java.util.Map;
  28. /**
  29. * Provides a basic implementation of the {@link ChannelClientInfo} interface.
  30. */
  31. public abstract class BaseChannelClientInfo implements ChannelClientInfo {
  32. /** A map for random data associated with the client to be stored in. */
  33. private final Map<Object, Object> map = new HashMap<>();
  34. /** The channel that the client is associated with. */
  35. private final ChannelInfo channel;
  36. /** The client that is associated with the channel. */
  37. private final ClientInfo client;
  38. /**
  39. * Creates a new BaseChannelClientInfo object for the specified client's
  40. * association with the specified channel.
  41. *
  42. * @param channel The channel the association is with
  43. * @param client The user that holds the association
  44. */
  45. public BaseChannelClientInfo(final ChannelInfo channel, final ClientInfo client) {
  46. this.channel = channel;
  47. this.client = client;
  48. }
  49. @Override
  50. public ChannelInfo getChannel() {
  51. return channel;
  52. }
  53. @Override
  54. public ClientInfo getClient() {
  55. return client;
  56. }
  57. @Override
  58. @SuppressWarnings("ReturnOfCollectionOrArrayField")
  59. public Map<Object, Object> getMap() {
  60. return map;
  61. }
  62. @Override
  63. public String toString() {
  64. return getImportantMode() + client;
  65. }
  66. }