Skip to content

Commit

Permalink
improve(yaml): add null checks for constructor, also remove unused im…
Browse files Browse the repository at this point in the history
…ports
  • Loading branch information
Siroshun09 committed Feb 23, 2024
1 parent 3717cb8 commit 4cf36b4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.github.siroshun09.configapi.core.comment.SimpleComment;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

/**
* A {@link SimpleComment} implementation that holds the block comments in Yaml.
*
Expand All @@ -32,6 +34,13 @@ public record YamlBlockComment(@NotNull String content, int prependBlankLines) i
*/
public static final String TYPE = "block";

public YamlBlockComment {
Objects.requireNonNull(content);
if (prependBlankLines < 0) {
throw new IllegalArgumentException("prependBlankLines cannot be negative.");
}
}

@Override
public @NotNull String type() {
return TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import com.github.siroshun09.configapi.core.comment.SimpleComment;
import org.jetbrains.annotations.NotNull;

import java.util.Objects;

/**
* A {@link SimpleComment} implementation that holds the inline comments in Yaml.
*
Expand All @@ -31,6 +33,10 @@ public record YamlInlineComment(@NotNull String content) implements SimpleCommen
*/
public static final String TYPE = "inline";

public YamlInlineComment {
Objects.requireNonNull(content);
}

@Override
public @NotNull String type() {
return TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package com.github.siroshun09.configapi.format.yaml.comment;

import com.github.siroshun09.configapi.core.comment.Comment;
import com.github.siroshun09.configapi.core.comment.SimpleComment;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
Expand Down

0 comments on commit 4cf36b4

Please sign in to comment.