Class DatabaseStructure<P,F extends DatabaseField<P>>

java.lang.Object
com.barden.library.database.mongo.structure.DatabaseStructure<P,F>
Type Parameters:
P - Parent object.
F - Database field enum.

public abstract class DatabaseStructure<P,F extends DatabaseField<P>> extends Object
Database structure class to handle database methods.
  • Field Details

  • Constructor Details

  • Method Details

    • getParent

      @NotNull public final P getParent()
      Gets parent.
      Returns:
      DatabaseStructure
    • getField

      @NotNull public final Class<F> getField()
      Gets field class.
      Returns:
      Class of DatabaseStructure
    • getMongoProvider

      @NotNull public DatabaseMongoProvider getMongoProvider()
      Gets mongo provider.
      Returns:
      DatabaseMongoProvider
    • save

      public void save(@NotNull F... fields)
      Saves database structure to the database.
      Parameters:
      fields - DatabaseStructure fields to save.
      Throws:
      NullPointerException - If is null.
    • save

      public void save(@NotNull Collection<F> fields)
      Saves database structure to the database.
      Parameters:
      fields - DatabaseStructure fields to save.
      Throws:
      NullPointerException - If is null.
    • save

      public void save()
      Saves database structure to the database with all fields.
    • saveAsync

      public void saveAsync(@NotNull F... fields)
      Saves database structure to the database async.
      Parameters:
      fields - DatabaseStructure fields to save.
    • saveAsync

      public void saveAsync(@NotNull Collection<F> fields)
      Saves database structure to the database. (ASYNC)
      Parameters:
      fields - DatabaseStructure fields to save.
    • saveAsync

      public final void saveAsync()
      Saves database structure to the database with all fields. (ASYNC)
    • delete

      public final void delete()
      Deletes database structure from the database.
    • deleteAsync

      public final void deleteAsync()
      Deletes database structure from the database. (ASYNC)
    • toQueryBson

      @NotNull public final org.bson.conversions.Bson toQueryBson()
      Gets query field.
      Returns:
      Bson
    • toSaveBson

      @NotNull public final org.bson.conversions.Bson toSaveBson()
      Gets parent as a save bson. With save bson, we can update mongo document.
      Returns:
      Bson
    • toSaveBson

      @SafeVarargs @NotNull public final org.bson.conversions.Bson toSaveBson(@NotNull F... fields)
      Gets save bson with target fields.
      Parameters:
      fields - DatabaseStructure fields to save.
      Returns:
      Bson
      Throws:
      NullPointerException - If is null.
    • toBsonValue

      @NotNull public final org.bson.BsonValue toBsonValue(@NotNull F field)
      Gets bson value from field.
      Parameters:
      field - DatabaseStructure field to get value from.
      Returns:
      Bson