com.dslplatform.json.runtime.AttributeArrayEncoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dsl-json-java8 Show documentation
Show all versions of dsl-json-java8 Show documentation
DSL Platform compatible Java JSON library (https://dsl-platform.com)
The newest version!
package com.dslplatform.json.runtime;
import com.dslplatform.json.JsonWriter;
import com.dslplatform.json.Nullable;
class AttributeArrayEncoder implements JsonWriter.WriteObject {
private final Settings.Function read;
private final JsonWriter.WriteObject encoder;
AttributeArrayEncoder(
final Settings.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, @Nullable final T value) {
final R attr = read.apply(value);
encoder.write(writer, attr);
}
}