Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Displayable.java 3.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (c) 2006-2016 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
  5. * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
  6. * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
  7. * permit persons to whom the Software is furnished to do so, subject to the following conditions:
  8. *
  9. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
  10. * Software.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  13. * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  14. * OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  15. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. */
  17. package com.dmdirc.interfaces;
  18. import com.dmdirc.events.DisplayProperty;
  19. import com.dmdirc.events.DisplayPropertyMap;
  20. import java.util.Optional;
  21. /**
  22. * Common interface for objects which may be displayed, and are affected by {@link DisplayProperty}s.
  23. */
  24. public interface Displayable {
  25. /**
  26. * Retrieves a property relating to how this object should be displayed.
  27. *
  28. * @param property The property to be retrieved.
  29. * @param <T> The type of value that the property takes.
  30. * @return An optional value for the property.
  31. */
  32. <T> Optional<T> getDisplayProperty(DisplayProperty<T> property);
  33. /**
  34. * Sets a property relating to how this object should be displayed.
  35. *
  36. * @param property The property to be set
  37. * @param value The value of the property
  38. * @param <T> The type of value that the property takes.
  39. */
  40. <T> void setDisplayProperty(DisplayProperty<T> property, T value);
  41. /**
  42. * Determines whether this object has a display property.
  43. *
  44. * <p>Only use this method if the value of the property does not matter; otherwise use
  45. * {@link #getDisplayProperty(DisplayProperty)} and use the appropriate {@link Optional}
  46. * accessors.
  47. *
  48. * @param property The property to be checked.
  49. * @return True if the property is present, false otherwise.
  50. */
  51. default boolean hasDisplayProperty(final DisplayProperty<?> property) {
  52. return getDisplayProperty(property).isPresent();
  53. }
  54. /**
  55. * Removes a property relating to how this object should be displayed.
  56. *
  57. * @param property The property to be removed
  58. */
  59. default <T> void removeDisplayProperty(final DisplayProperty<T> property) {
  60. getDisplayProperties().remove(property);
  61. }
  62. /**
  63. * Gets the map of all display properties.
  64. *
  65. * @return The map of display properties.
  66. */
  67. DisplayPropertyMap getDisplayProperties();
  68. }