Class MockUtils

java.lang.Object
com.vaadin.browserless.mocks.MockUtils

public final class MockUtils extends Object
Helpers shared by the mocks in this package.

For internal use only. May be renamed or removed in a future release.

  • Method Details

    • putOrRemove

      public static <K, V> void putOrRemove(Map<K,V> map, K key, V value)
      Stores the value under the key, or removes the key when the value is null.

      This is what the servlet API asks for: setting an attribute to null removes it. It also keeps the mocks usable with a map that rejects null values, such as ConcurrentHashMap.

      Type Parameters:
      K - the key type
      V - the value type
      Parameters:
      map - the map to modify
      key - the key to store under or remove
      value - the value to store, or null to remove the key