/src/main/java/de/jbee/lang/Map.java

http://github.com/jbee/jadamant · Java · 85 lines · 40 code · 23 blank · 22 comment · 0 complexity · fdea74aaf58dfa6e95d9ffdd7420d406 MD5 · raw file

  1. package de.jbee.lang;
  2. import static de.jbee.lang.Order.entryKeysBy;
  3. import static de.jbee.lang.Order.typeaware;
  4. import de.jbee.lang.seq.UtileMapLister;
  5. /**
  6. * A {@linkplain Map} is a special case of {@link Multimap} where each key may just refer to one
  7. * value or in other words its a {@link Set} or {@link Entry}s where equality is given by equal
  8. * keys.
  9. *
  10. * @author Jan Bernitt (jan.bernitt@gmx.de)
  11. */
  12. public interface Map<V>
  13. extends Set<Map.Entry<V>>, Multimap<V> {
  14. MapLister with = new UtileMapLister();
  15. @Override
  16. Map<V> deleteAt( int index );
  17. @Override
  18. Map<V> drop( int count );
  19. /**
  20. * There will be one or none so we know that the {@link Map}-constraint won't be violated.
  21. */
  22. @Override
  23. Map<V> entriesAt( int index );
  24. /**
  25. * In case a entry with the same key already exists the key's value is redefined and the
  26. * <code>value</code> given (and only that value) is associated with the key from now on.
  27. */
  28. @Override
  29. Map<V> insert( Key key, V value );
  30. @Override
  31. Map<V> insert( Map.Entry<V> e );
  32. @Override
  33. Map<V> subsequent();
  34. @Override
  35. Map<V> take( int count );
  36. @Override
  37. Map<V> tidyUp();
  38. interface Key {
  39. /**
  40. * The terminator is the highest unicode character existing. It is appended to the searched
  41. * prefix to find the position between the last key having the prefix and the first one that
  42. * does not.
  43. */
  44. String PREFIX_TERMINATOR = "\ufffd";
  45. String path();
  46. }
  47. interface NumericalKey
  48. extends Key {
  49. int code();
  50. }
  51. interface Entry<V>
  52. extends Element<V> {
  53. /**
  54. * Default order used for all {@link Map}s. The keys are sorted alphabetical.
  55. */
  56. Ord<Object> ORDER = typeaware( entryKeysBy( Order.alphabetical ), Entry.class );
  57. Key key();
  58. }
  59. interface MapLister {
  60. <E> Map<E> noEntries( Ord<Object> order );
  61. }
  62. }