All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dslplatform.json.runtime.AttributeArrayEncoder Maven / Gradle / Ivy

There is a newer version: 1.10.0
Show newest version
package com.dslplatform.json.runtime;

import com.dslplatform.json.JsonWriter;

import java.util.function.Function;

class AttributeArrayEncoder implements JsonWriter.WriteObject {

	private final Function read;
	private final JsonWriter.WriteObject encoder;

	AttributeArrayEncoder(
			final Function read,
			final JsonWriter.WriteObject encoder) {
		if (read == null) throw new IllegalArgumentException("read can't be null");
		if (encoder == null) throw new IllegalArgumentException("encoder can't be null");
		this.read = read;
		this.encoder = encoder;
	}

	@Override
	public void write(final JsonWriter writer, final T value) {
		final R attr = read.apply(value);
		encoder.write(writer, attr);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy