summaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/pcj/json/MapCodec.java
blob: 468e4cfc7ce614216a74a2d9de0d3b1ba27f7a4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package moe.nea.pcj.json;

import moe.nea.pcj.Result;

import java.util.function.Function;

public interface MapCodec<T, Format> {
	Result<T, JsonLikeError> decode(
			RecordView<Format> record,
			JsonLikeOperations<Format> ops);

	Result<RecordBuilder<Format>, JsonLikeError> encode(T value, JsonLikeOperations<Format> ops);

	default <O> RecordCodec<O, T, Format> withGetter(Function<O, T> getter) {
		return new RecordCodec<>(this, getter);
	}
}