Class EmbedCache

java.lang.Object
com.github.kaktushose.jda.commands.embeds.EmbedCache

public class EmbedCache extends Object
This class loads and caches embeds from a json file.
See Also:
  • Constructor Details

    • EmbedCache

      public EmbedCache(File file)
      Constructs a new EmbedCache object.
      Parameters:
      file - the file to load the embeds from
    • EmbedCache

      public EmbedCache(InputStream stream)
      Constructs a new EmbedCache object.
      Parameters:
      stream - the stream to load the embeds from
    • EmbedCache

      public EmbedCache(String file)
      Constructs a new EmbedCache object.
      Parameters:
      file - the path to the file to load the embeds from
  • Method Details

    • loadEmbeds

      public void loadEmbeds()
      Loads all embeds from a file and stores them. This happens automatically each time you construct a new EmbedCache. Thus, it's not needed to call this method manually, unless you want to reload the embeds.
    • getEmbed

      public EmbedDTO getEmbed(@Nonnull String name)
      Gets an embed from the cache.
      Parameters:
      name - the name the EmbedDTO is mapped to
      Returns:
      the EmbedDTO or null if the cache contains no mapping for the key
    • isEmpty

      public boolean isEmpty()
      Returns true if this cache contains no EmbedDTOs.
      Returns:
      true if this cache contains no EmbedDTOs.
    • size

      public int size()
      Returns the number of EmbedDTOs in this cache.
      Returns:
      the number of EmbedDTOs in this cache.
    • containsEmbed

      public boolean containsEmbed(@Nonnull String name)
      Returns true if this cache contains a mapping for the specified name.
      Parameters:
      name - the name the EmbedDTO is mapped to
      Returns:
      true if this cache contains a mapping for the specified name.
    • values

      public List<EmbedDTO> values()
      Returns an unmodifiable List containing all EmbedDTO of this cache.
      Returns:
      an unmodifiable List containing all EmbedDTO of this cache.