Skip to content

Commit 128e5b0

Browse files
committed
chore(font): rework font entity structure
1 parent 0bc0c51 commit 128e5b0

2 files changed

Lines changed: 38 additions & 5 deletions

File tree

src/main/java/net/onelitefeather/vulpes/api/model/FontEntity.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package net.onelitefeather.vulpes.api.model;
22

3+
import jakarta.persistence.CascadeType;
34
import jakarta.persistence.ElementCollection;
45
import jakarta.persistence.Entity;
56
import jakarta.persistence.GeneratedValue;
67
import jakarta.persistence.GenerationType;
78
import jakarta.persistence.Id;
9+
import jakarta.persistence.OneToMany;
10+
import jakarta.persistence.OneToOne;
811
import net.onelitefeather.vulpes.api.generator.VulpesGenerator;
12+
import net.onelitefeather.vulpes.api.model.font.FontLoreEntity;
913

1014
import java.util.List;
1115
import java.util.UUID;
@@ -34,8 +38,8 @@ public class FontEntity implements VulpesModel {
3438
private String comment;
3539
private int height;
3640
private int ascent;
37-
@ElementCollection
38-
private List<String> chars;
41+
@OneToMany(cascade = CascadeType.ALL)
42+
private List<FontLoreEntity> chars;
3943

4044
/**
4145
* Default constructor for JPA and Micronaut Data.
@@ -60,7 +64,17 @@ public FontEntity() {
6064
* @param ascent the ascent of the font
6165
* @param chars the list of characters included in the font
6266
*/
63-
public FontEntity(UUID id, String uiName, String variableName, String provider, String texturePath, String comment, int height, int ascent, List<String> chars) {
67+
public FontEntity(
68+
UUID id,
69+
String uiName,
70+
String variableName,
71+
String provider,
72+
String texturePath,
73+
String comment,
74+
int height,
75+
int ascent,
76+
List<FontLoreEntity> chars
77+
) {
6478
this.id = id;
6579
this.uiName = uiName;
6680
this.variableName = variableName;
@@ -181,7 +195,7 @@ public void setHeight(int height) {
181195
*
182196
* @return the list of characters in the font
183197
*/
184-
public List<String> getChars() {
198+
public List<FontLoreEntity> getChars() {
185199
return chars;
186200
}
187201

@@ -190,7 +204,7 @@ public List<String> getChars() {
190204
*
191205
* @param chars the list of characters to set
192206
*/
193-
public void setChars(List<String> chars) {
207+
public void setChars(List<FontLoreEntity> chars) {
194208
this.chars = chars;
195209
}
196210

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package net.onelitefeather.vulpes.api.model.font;
2+
3+
import jakarta.persistence.Entity;
4+
import jakarta.persistence.GeneratedValue;
5+
import jakarta.persistence.GenerationType;
6+
import jakarta.persistence.Id;
7+
import net.onelitefeather.vulpes.api.generator.VulpesGenerator;
8+
9+
import java.util.UUID;
10+
11+
@Entity(name = "font_lore")
12+
public record FontLoreEntity(
13+
@Id
14+
@GeneratedValue(strategy = GenerationType.UUID)
15+
@VulpesGenerator
16+
UUID id,
17+
String line
18+
) {
19+
}

0 commit comments

Comments
 (0)