Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Event.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright 2000-2014 Vaadin Ltd.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  5. * use this file except in compliance with the License. You may obtain a copy of
  6. * the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  12. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  13. * License for the specific language governing permissions and limitations under
  14. * the License.
  15. */
  16. package com.vaadin.tokka.event;
  17. import java.util.EventObject;
  18. import com.vaadin.server.ClientConnector;
  19. /**
  20. * Generic event object typed for pay load.
  21. *
  22. * @since
  23. * @param <T>
  24. * pay load type
  25. */
  26. public class Event<T> extends EventObject {
  27. /**
  28. * Pay load value.
  29. */
  30. private final T value;
  31. /**
  32. * {@code true} if event from a client-side update, {@code false} if from an
  33. * API call.
  34. */
  35. private final boolean userOriginated;
  36. /**
  37. * Constructs a new event object with source, value and origin.
  38. *
  39. * @param source
  40. * source component
  41. * @param value
  42. * pay load value
  43. * @param userOriginated
  44. * is the event from API call or client update
  45. */
  46. public Event(ClientConnector source, T value, boolean userOriginated) {
  47. super(source);
  48. this.value = value;
  49. this.userOriginated = userOriginated;
  50. }
  51. /**
  52. * Gets the payload value.
  53. *
  54. * @return payload value
  55. */
  56. public T getValue() {
  57. return value;
  58. }
  59. /**
  60. * Gets the origin of this event.
  61. *
  62. * @return {@code true} if update from client-side; {@code false} if from
  63. * API call
  64. */
  65. public boolean isUserOriginated() {
  66. return userOriginated;
  67. }
  68. @Override
  69. public ClientConnector getSource() {
  70. return (ClientConnector) super.getSource();
  71. }
  72. }