Skip to content

Commit

Permalink
YamlMappingBuilder reorder + defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
amihaiemil committed May 7, 2024
1 parent 77aff69 commit 5b74802
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 53 deletions.
18 changes: 0 additions & 18 deletions src/main/java/com/amihaiemil/eoyaml/MutableYamlMappingBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,6 @@ final class MutableYamlMappingBuilder implements YamlMappingBuilder {
this.pairs = pairs;
}

@Override
public YamlMappingBuilder add(final String key, final String value) {
return this.add(
new PlainStringScalar(key),
new PlainStringScalar(value)
);
}

@Override
public YamlMappingBuilder add(final YamlNode key, final String value) {
return this.add(key, new PlainStringScalar(value));
}

@Override
public YamlMappingBuilder add(final String key, final YamlNode value) {
return this.add(new PlainStringScalar(key), value);
}

@Override
public YamlMappingBuilder add(final YamlNode key, final YamlNode value) {
if(key == null || key.isEmpty()) {
Expand Down
18 changes: 0 additions & 18 deletions src/main/java/com/amihaiemil/eoyaml/RtYamlMappingBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,24 +60,6 @@ final class RtYamlMappingBuilder implements YamlMappingBuilder {
this.pairs = pairs;
}

@Override
public YamlMappingBuilder add(final String key, final String value) {
return this.add(
new PlainStringScalar(key),
new PlainStringScalar(value)
);
}

@Override
public YamlMappingBuilder add(final YamlNode key, final String value) {
return this.add(key, new PlainStringScalar(value));
}

@Override
public YamlMappingBuilder add(final String key, final YamlNode value) {
return this.add(new PlainStringScalar(key), value);
}

@Override
public YamlMappingBuilder add(final YamlNode key, final YamlNode value) {
if(key == null || key.isEmpty()) {
Expand Down
44 changes: 27 additions & 17 deletions src/main/java/com/amihaiemil/eoyaml/YamlMappingBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,47 +39,47 @@
* @since 1.0.0
*/
public interface YamlMappingBuilder {
/**
* Add a pair to the mapping.
* @param key String
* @param value String
* @return Builder
*/
YamlMappingBuilder add(final String key, final String value);

/**
* Add a pair to the mapping.
* @param key YamlNode (sequence or mapping)
* @param value String
* @param value YamlNode (sequence or mapping)
* @return Builder
*/
YamlMappingBuilder add(final YamlNode key, final String value);
YamlMappingBuilder add(final YamlNode key, final YamlNode value);

/**
* Add a pair to the mapping.
* @param key YamlNode (sequence or mapping)
* @param value YamlNode (sequence or mapping)
* @param key String
* @param value String
* @return Builder
*/
YamlMappingBuilder add(final YamlNode key, final YamlNode value);
default YamlMappingBuilder add(final String key, final String value) {
return this.add(
new PlainStringScalar(key),
new PlainStringScalar(value)
);
}

/**
* Add a pair to the mapping.
* @param key String
* @param value YamlNode (sequence or mapping)
* @return Builder
*/
YamlMappingBuilder add(final String key, final YamlNode value);
default YamlMappingBuilder add(final String key, final YamlNode value) {
return this.add(new PlainStringScalar(key), value);
}

/**
* Add a pair to the mapping.
* @param key YamlNode (sequence or mapping)
* @param key String
* @param value JsonStructure ({@link javax.json.JsonObject}
* or {@link javax.json.JsonArray})
* @return Builder
*/
default YamlMappingBuilder add(
final YamlNode key, final JsonStructure value
final String key, final JsonStructure value
) {
final YamlNode node;
if(value instanceof JsonObject) {
Expand All @@ -92,13 +92,23 @@ default YamlMappingBuilder add(

/**
* Add a pair to the mapping.
* @param key String
* @param key YamlNode (sequence or mapping)
* @param value String
* @return Builder
*/
default YamlMappingBuilder add(final YamlNode key, final String value) {
return this.add(key, new PlainStringScalar(value));
}

/**
* Add a pair to the mapping.
* @param key YamlNode (sequence or mapping)
* @param value JsonStructure ({@link javax.json.JsonObject}
* or {@link javax.json.JsonArray})
* @return Builder
*/
default YamlMappingBuilder add(
final String key, final JsonStructure value
final YamlNode key, final JsonStructure value
) {
final YamlNode node;
if(value instanceof JsonObject) {
Expand Down

0 comments on commit 5b74802

Please sign in to comment.