Page cover image

Records

public class YourRecordName implements Record<YourRecordName> {

Primary fields represent a unique identifier for the record. They are declared with the @Primary annotation.

public static final @NotNull String IDENTIFIER_KEY = "identifier";

private final @Field(IDENTIFIER_KEY) @Primary @NotNull String identifier;
    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;
    }
}

Supported Types

Type
Status
Description

String

Implemented

Boolean

Implemented

Integer

Implemented

Long

Implemented

Float

Implemented

Double

Implemented

Default

Implemented

If there is a data type you want to use that isnt included above it will convert it into a json and store as a string.

Last updated