io.permazen.util.MapEntryConverter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of permazen-util Show documentation
Show all versions of permazen-util Show documentation
Common utility classes used by Permazen.
The newest version!
/*
* Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
*/
package io.permazen.util;
import com.google.common.base.Converter;
import java.util.Map;
/**
* Converts {@link Map.Entry}s.
*
* @param key type of this map
* @param value type of this map
* @param key type of wrapped map
* @param value type of wrapped map
*/
class MapEntryConverter extends Converter, Map.Entry> {
private final Converter keyConverter;
private final Converter valueConverter;
MapEntryConverter(Converter keyConverter, Converter valueConverter) {
this.keyConverter = keyConverter;
this.valueConverter = valueConverter;
}
@Override
protected Map.Entry doForward(Map.Entry entry) {
if (entry == null)
return null;
return new ConvertedMapEntry(this.keyConverter.reverse(), this.valueConverter.reverse(), entry);
}
@Override
protected Map.Entry doBackward(Map.Entry wentry) {
if (wentry == null)
return null;
return new ConvertedMapEntry<>(this.keyConverter, this.valueConverter, wentry);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy