選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

DataGenerator.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright 2000-2016 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.data.provider;
  17. import java.io.Serializable;
  18. import elemental.json.JsonObject;
  19. /**
  20. * A data generator for {@link DataCommunicator}. Used to inject custom data to
  21. * data items sent to the client for extension purposes.
  22. *
  23. * @author Vaadin Ltd.
  24. *
  25. * @param <T>
  26. * the data type
  27. *
  28. * @since 8.0
  29. */
  30. @FunctionalInterface
  31. public interface DataGenerator<T> extends Serializable {
  32. /**
  33. * Adds custom data for the given item to its serialized {@code JsonObject}
  34. * representation. This JSON object will be sent to client-side
  35. * DataProvider.
  36. *
  37. * @param item
  38. * the data item being serialized
  39. * @param jsonObject
  40. * the JSON object being sent to the client
  41. */
  42. void generateData(T item, JsonObject jsonObject);
  43. /**
  44. * Informs the {@code DataGenerator} that the given data item has been
  45. * dropped and is no longer needed. This method should clean up any unneeded
  46. * information stored for this item.
  47. *
  48. * @param item
  49. * the dropped data item
  50. */
  51. public default void destroyData(T item) {
  52. }
  53. /**
  54. * Informs the {@code DataGenerator} that all data has been dropped. This
  55. * method should clean up any unneeded information stored for items.
  56. */
  57. public default void destroyAllData() {
  58. }
  59. /**
  60. * Informs the {@code DataGenerator} that a data object has been updated.
  61. * This method should update any unneeded information stored for given item.
  62. *
  63. * @param item
  64. * the updated item
  65. */
  66. public default void refreshData(T item) {
  67. }
  68. }