2 * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.plugin.generator.api;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import com.google.common.io.ByteSource;
14 import java.io.IOException;
15 import java.io.OutputStream;
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
20 * A generated file with a body is available as a {@link ByteSource}.
23 final class ByteSourceGeneratedFile extends AbstractGeneratedFile {
24 private final ByteSource body;
26 ByteSourceGeneratedFile(final GeneratedFileLifecycle lifecycle, final ByteSource body) {
28 this.body = requireNonNull(body);
32 public void writeBody(final @NonNull OutputStream output) throws IOException {
37 protected ToStringHelper addToStringAttributes(final ToStringHelper helper) {
38 return helper.add("body", body);