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.

DataKeyMapper.java 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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.server.communication.data;
  17. import java.io.Serializable;
  18. /**
  19. * DataKeyMapper to map data objects to key strings.
  20. *
  21. * @since
  22. * @param <T>
  23. * data type
  24. */
  25. public interface DataKeyMapper<T> extends Serializable {
  26. /**
  27. * Gets the key for data object. If no key exists beforehand, a new key is
  28. * created.
  29. *
  30. * @param dataObject
  31. * data object for key mapping
  32. * @return key for given data object
  33. */
  34. String key(T dataObject);
  35. /**
  36. * Gets the data object identified by given key.
  37. *
  38. * @param key
  39. * key of a data object
  40. * @return identified data object; <code>null</code> if invalid key
  41. */
  42. T get(String key);
  43. /**
  44. * Removes a data object from the key mapping. The key is also dropped.
  45. * Dropped keys are not reused.
  46. *
  47. * @param dataObject
  48. * dropped data object
  49. */
  50. void remove(T dataObject);
  51. /**
  52. * Removes all data objects from the key mapping. The keys are also dropped.
  53. * Dropped keys are not reused.
  54. */
  55. void removeAll();
  56. }