
net.hamnaberg.json.JsonCodec Maven / Gradle / Ivy
package net.hamnaberg.json;
import java.util.Optional;
import java.util.function.Function;
public interface JsonCodec extends EncodeJson, DecodeJson {
default JsonCodec xmap(Function f1, Function f2) {
JsonCodec that = this;
return new JsonCodec() {
@Override
public Optional fromJson(Json.JValue value) {
return that.fromJson(value).map(f1);
}
@Override
public Optional toJson(B value) {
return that.toJson(f2.apply(value));
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy