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.

Profile.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (c) 2006-2014 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.config.profiles;
  23. import com.google.common.base.MoreObjects;
  24. import com.google.common.collect.Lists;
  25. import java.util.Collections;
  26. import java.util.List;
  27. import java.util.Objects;
  28. import java.util.Optional;
  29. /**
  30. * Describes a profile, used to describe the settings associated with the local client on a
  31. * connection.
  32. */
  33. public class Profile {
  34. /** Profile Name, must be a sanitised filename. */
  35. private final String name;
  36. /** Real name. */
  37. private final String realname;
  38. /** Ident. */
  39. private final Optional<String> ident;
  40. /** Nicknames. */
  41. private final List<String> nicknames;
  42. public Profile(final String name, final String realname, final Optional<String> ident,
  43. final Iterable<String> nicknames) {
  44. this.name = name;
  45. this.realname = realname;
  46. this.ident = ident;
  47. this.nicknames = Lists.newArrayList(nicknames);
  48. }
  49. public String getName() {
  50. return name;
  51. }
  52. public String getRealname() {
  53. return realname;
  54. }
  55. public Optional<String> getIdent() {
  56. return ident;
  57. }
  58. public List<String> getNicknames() {
  59. return Collections.unmodifiableList(nicknames);
  60. }
  61. public String toString() {
  62. return MoreObjects.toStringHelper(this)
  63. .add("name", name)
  64. .add("realname", realname)
  65. .add("ident", ident)
  66. .add("nicknames", nicknames)
  67. .toString();
  68. }
  69. @Override
  70. public boolean equals(final Object o) {
  71. if (this == o) {
  72. return true;
  73. }
  74. if (o == null || getClass() != o.getClass()) {
  75. return false;
  76. }
  77. final Profile profile = (Profile) o;
  78. return Objects.equals(name, profile.getName())
  79. && Objects.equals(realname, profile.getRealname())
  80. && Objects.equals(nicknames, profile.getNicknames())
  81. && Objects.equals(ident, profile.getIdent());
  82. }
  83. @Override
  84. public int hashCode() {
  85. return Objects.hash(name, realname, ident, nicknames);
  86. }
  87. }