![JAR search and dependency download from the Maven repository](/logo.png)
org.jhotdraw8.icollection.impl.champmap.EditableMapEntry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.jhotdraw8.icollection Show documentation
Show all versions of org.jhotdraw8.icollection Show documentation
JHotDraw8 Immutable Collections
The newest version!
/*
* @(#)EditableMapEntry.java
* Copyright © 2022 The authors and contributors of JHotDraw. MIT License.
*/
package org.jhotdraw8.icollection.impl.champmap;
import org.jspecify.annotations.Nullable;
import java.io.Serial;
import java.util.AbstractMap;
import java.util.function.BiConsumer;
/**
* A map entry that supports a put operation.
*
* @param the key type
* @param the value type
*/
public class EditableMapEntry extends AbstractMap.SimpleEntry {
@Serial
private static final long serialVersionUID = 0L;
private final int sequenceNumber;
@SuppressWarnings({"serial", "RedundantSuppression"})
private @Nullable BiConsumer putIfPresentFunction;// This map entry is actually not serializable
public EditableMapEntry(K key, V value, int sequenceNumber) {
super(key, value);
this.sequenceNumber = sequenceNumber;
}
public int getSequenceNumber() {
return sequenceNumber;
}
void setPutIfPresentFunction(@Nullable BiConsumer putIfPresentFunction) {
this.putIfPresentFunction = putIfPresentFunction;
}
@Override
public V setValue(V value) {
if (putIfPresentFunction == null) {
throw new UnsupportedOperationException();
}
putIfPresentFunction.accept(getKey(), value);
return super.setValue(value);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy