net.hamnaberg.json.codec.EncodeJson Maven / Gradle / Ivy
The newest version!
package net.hamnaberg.json.codec;
import net.hamnaberg.json.Json;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
public interface EncodeJson {
Json.JValue toJson(A value);
@Deprecated
default Json.JValue toJsonUnsafe(A value) {
return toJson(value);
}
default EncodeJson contramap(Function f) {
return value -> this.toJson(f.apply(value));
}
default FieldEncoder fieldEncoder(String name) {
return FieldEncoder.typedFieldOf(name, this);
}
default EncodeJson> option() {
return Encoders.optionalencoder(this);
}
default EncodeJson> list() {
return Encoders.listEncoder(this);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy