public class YourRecordName implements Record<YourRecordName> {
public TestRecord(@NotNull String identifier) {
this.identifier = identifier;
this.string = "The default value.";
this.bool = true;
this.object = new ObjectTest();
this.foreign = "The default value.";
}
To read and write the record we fill in the convert methods. This is how it is "sterilized".
@Override
public @NotNull ConfigurationSection convert() {
ConfigurationSection section = new MemoryConfigurationSection();
section.set(IDENTIFIER_KEY, this.identifier);
section.set(TestRecord.STRING_KEY, this.string);
section.set(TestRecord.BOOL_KEY, this.bool);
section.set(TestRecord.OBJECT_KEY, this.object);
section.set(TestRecord.OTHER_TABLE_IDENTIFIER, this.foreign);
return section;
}
@Override
public @NotNull TestRecord convert(@NotNull ConfigurationSection section) {
this.string = section.getString(TestRecord.STRING_KEY);
this.bool = section.getBoolean(TestRecord.BOOL_KEY);
this.object = section.getClass(TestRecord.OBJECT_KEY, ObjectTest.class);
this.foreign = section.getString(TestRecord.OTHER_TABLE_IDENTIFIER);
return this;
}
}