Skip to content

Commit

Permalink
Add name property to branches
Browse files Browse the repository at this point in the history
  • Loading branch information
mnhock authored and mnhock committed Sep 26, 2023
1 parent b0cbd7a commit 9593fa7
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
25 changes: 25 additions & 0 deletions src/main/java/com/enofex/naikan/model/Branch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.enofex.naikan.model;

public record Branch(String name) {

public static Builder builder() {
return new Builder();
}

public static final class Builder {

private String name;

private Builder() {
}

public Builder name(String name) {
this.name = name;
return this;
}

public Branch build() {
return new Branch(this.name);
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/enofex/naikan/model/Branches.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import java.util.List;

public final class Branches extends AbstractContainer<String> {
public final class Branches extends AbstractContainer<Branch> {

private static final Branches NO_BRANCHES = new Branches(List.of());

public Branches(List<String> branches) {
public Branches(List<Branch> branches) {
super(branches);
}

public static Branches empty() {
return NO_BRANCHES;
}

public static Branches of(String... branches) {
public static Branches of(Branch... branches) {
return new Branches(List.of(branches));
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.enofex.naikan.model.module;

import com.enofex.naikan.model.Branch;
import com.enofex.naikan.model.Branches;
import com.enofex.naikan.model.Tags;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import java.io.IOException;
Expand All @@ -16,13 +16,13 @@ final class BranchesDeserializer extends AbstractDeserializer<Branches> {
static final BranchesDeserializer INSTANCE = new BranchesDeserializer();

BranchesDeserializer() {
super(Tags.class, Branches.empty());
super(Branches.class, Branches.empty());
}

@Override
public Branches deserialize(JsonParser jsonParser, DeserializationContext ctx)
throws IOException {
String[] branches = jsonParser.readValueAs(String[].class);
Branch[] branches = jsonParser.readValueAs(Branch[].class);

return new Branches(List.of(branches));
}
Expand Down
7 changes: 6 additions & 1 deletion src/main/resources/bom-1.0.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,12 @@
"type": "array",
"items": [
{
"type": "string"
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
}
]
},
Expand Down

0 comments on commit 9593fa7

Please sign in to comment.