/*
 * Copyright 2018, TeamDev. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package io.spine.js.generate.output.snippet;

import io.spine.js.generate.output.CodeLine;

import static com.google.common.base.Preconditions.checkNotNull;

/**
 * A single-lined comment.
 */
public class Comment extends CodeLine {

    private final String text;

    private Comment(String text) {
        super();
        checkNotNull(text);
        this.text = text;
    }

    /**
     * Obtains the comment from the specified text.
     */
    public static Comment of(String text) {
        return new Comment(text);
    }

    /**
     * Obtains the comment to mark generated code.
     */
    public static Comment generatedBySpine() {
        return new Comment("Generated by Spine ProtoJs Plugin");
    }

    @Override
    public String content() {
        return "// " + text;
    }
}

@@ -1184,17 +1184,16 @@
 gle-line
-d
  comment
@@ -1264,19 +1264,22 @@
  String 
+con
 te
-x
+n
 t;%0A%0A    
@@ -1293,35 +1293,38 @@
  Comment(String 
+con
 te
-x
+n
 t) %7B%0A        sup
@@ -1350,19 +1350,22 @@
 NotNull(
+con
 te
-x
+n
 t);%0A    
@@ -1377,18 +1377,24 @@
 his.
+con
 te
-x
+n
 t = 
+con
 te
-x
+n
 t;%0A 
@@ -1538,16 +1538,24 @@
 Comment(
+%22// %22 + 
 text);%0A 
@@ -1805,27 +1805,22 @@
  return 
-%22// %22 + tex
+conten
 t;%0A    %7D

Compose the result of `Comment.content()` only once