public static final @NotNull String IDENTIFIER_KEY = "identifier";
private final @Field(IDENTIFIER_KEY) @Primary @NotNull String identifier;Records
public class YourRecordName implements Record<YourRecordName> {public static final @NotNull String STRING_KEY = "value";
public static final @NotNull String BOOL_KEY = "bool";
public static final @NotNull String OBJECT_KEY = "object";
private @Field(STRING_KEY) String string;
private @Field(BOOL_KEY) boolean bool;
private @Field(OBJECT_KEY) ExampleObject object;public class ExampleObject {
private final @NotNull String testString = "test";
private int testInt = 123;
}public static final @NotNull String OTHER_TABLE_IDENTIFIER
= "other_table_identifier";
@Field(OTHER_TABLE_IDENTIFIER)
@Foreign(
table = OtherTable.TABLE_NAME,
tableField = OtherRecord.IDENTIFIER_KEY
)
private String foreign; 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.";
} @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;
}
}Supported Types
Type
Status
Description
Last updated