/*
 * Copyright 2000-2010 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package consulo.util.dataholder;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public interface UserDataHolder {
  @Nullable
  <T> T getUserData(@Nonnull Key<T> key);

  <T> void putUserData(@Nonnull Key<T> key, @Nullable T value);
}
@@ -694,16 +694,42 @@
 ullable;
+%0Aimport java.util.Objects;
 %0A%0Apublic
@@ -874,10 +874,754 @@
  value);
+%0A%0A  /**%0A   * @return written value%0A   */%0A  @Nonnull%0A  default %3CT%3E T putUserDataIfAbsent(@Nonnull Key%3CT%3E key, @Nonnull T value) %7B%0A    T oldValue = getUserData(key);%0A    if (oldValue == null) %7B%0A      putUserData(key, value);%0A      return value;%0A    %7D%0A    else %7B%0A      return oldValue;%0A    %7D%0A  %7D%0A%0A  /**%0A   * Replaces (atomically) old value in the map with the new one%0A   *%0A   * @return true if old value got replaced, false otherwise%0A   * @see ConcurrentMap#replace(Object, Object, Object)%0A   */%0A  default %3CT%3E boolean replace(@Nonnull Key%3CT%3E key, @Nullable T oldValue, @Nullable T newValue) %7B%0A    T data = getUserData(key);%0A%0A    if (!Objects.equals(data, oldValue)) %7B%0A      return false;%0A    %7D%0A%0A    putUserData(key, newValue);%0A    return true;%0A  %7D
 %0A%7D

add default methods from Ex class