Skip to content

0.1.5.0.BETA.2 | Interface Entites

Latest

Choose a tag to compare

@Hacking-Pancakez Hacking-Pancakez released this 30 Aug 21:36
· 9 commits to modularity since this release

Release Notes for 0.1.5.0.BETA.2 | Interface Entities

New Features

ClientPersonalJavaDexBuilder Class

  • Introduction: A new ClientPersonalJavaDexBuilder class has been added, which extends JavaDexBuilder. This class is designed to facilitate the creation of JavaDex instances with client credentials (client ID, client secret, username, password).
  • Default Refresh Rate: The class includes a default token refresh rate of 15 minutes, which can be customized via the setRefreshRate(Duration refreshRate) method. Users are cautioned against altering the refresh rate unless necessary due to potential issues with authenticated endpoints.
  • Build Method: The build() method in this class performs authentication using the provided client credentials and constructs a JavaDex instance.
ClientPersonalJavaDexBuilder builder = JavaDexBuilder.createPersonal("clientId")
    .setClientSecret("clientSecret")
    .setUsername("username")
    .setPassword("password");
JavaDex javaDex = builder.build();

Enhancements

JavaDex Class Enhancements

  • Authenticator Retrieval: A new getAuthenticator() method has been added to the JavaDex class. This method allows users to access the Authenticator object associated with a JavaDex instance, providing more flexibility for handling authentication-related tasks.
Authenticator authenticator = javaDex.getAuthenticator();
  • Method Renaming: The method getMangaById(String id) has been renamed to retrieveMangaById(String id). This change clarifies the method's purpose, emphasizing that it retrieves a manga object by its ID.
Manga manga = javaDex.retrieveMangaById("mangaId").get();
  • Follow Checking: A new method isFollowingManga(Manga manga) was introduced. It checks whether the authenticated user is following a specific manga by making an API request to MangaDex. The method handles HTTP responses and logs any unexpected codes, improving error handling and user feedback.
boolean isFollowing = javaDex.isFollowingManga(manga).get();
  • Retrieve Following Groups and Lists: The retrieveFollowingGroups() method has been updated to use a FollowsAction object, enhancing the ability to chain actions related to following scanlation groups. A new method, retrieveFollowingLists(), was added to similarly retrieve custom lists followed by the user.
List<ScanlationGroup> groups = javaDex.retrieveFollowingGroups().get();
List<MDList> lists = javaDex.retrieveFollowingLists().get();

API Changes

Refactor of JavaDexBuilder

  • Abstract Base Class: The JavaDexBuilder class has been refactored into an abstract class. This change lays the groundwork for different types of builders (e.g., ClientPersonalJavaDexBuilder) that handle various authentication scenarios, increasing the API's flexibility.
public abstract class JavaDexBuilder {
    // Abstract methods and common functionality
}
  • ClientPersonalJavaDexBuilder Creation: Users can now create instances using ClientPersonalJavaDexBuilder.createPersonal(String clientId) or ClientPersonalJavaDexBuilder.createPersonal() methods. This change ensures a more structured approach to creating authenticated instances.
ClientPersonalJavaDexBuilder builder = JavaDexBuilder.createPersonal("clientId");
  • Deprecated Builder Methods: Previous methods in JavaDexBuilder that directly accepted client credentials (e.g., setClientId, setClientSecret) have been deprecated. Users are encouraged to switch to ClientPersonalJavaDexBuilder.

Entity Interfaces

  • Refactoring Entities: Several classes such as Author, Chapter, MDList, Manga, ScanlationGroup, and User have been refactored into interfaces. This refactoring supports a more modular architecture, where entities are defined by their capabilities rather than their internal structure. This change improves the codebase's maintainability and extensibility.
public interface Manga {
    String getTitle();
    String getId();
    // Other methods
}

Entity Method Updates

  • Chapter Interface: Introduced methods such as getVolume(), getChapterNumber(), and retrieveScanlationGroups() that provide detailed access to chapter information, including its relationships with other entities.
public interface Chapter {
    String getVolume();
    String getChapterNumber();
    CompletableFuture<List<ScanlationGroup>> retrieveScanlationGroups();
    // other methods...
}
  • Manga Interface: Enhanced with methods like doChapterNumbersResetOnNewVolume(), getState(), retrieveCurrentCover(), and retrieveStatistics(). These methods offer comprehensive access to the metadata and statistics of manga on MangaDex.
public interface Manga {
    boolean doChapterNumbersResetOnNewVolume();
    String getState();
    CompletableFuture<Cover> retrieveCurrentCover();
    CompletableFuture<Statistics> retrieveStatistics();
   // other methods
}
  • ScanlationGroup Interface: Added methods to retrieve details such as getWebsite(), getIrcServer(), getDiscord(), and getMembers(). These provide better insights into the scanlation groups' public information and organizational structure.
public interface ScanlationGroup {
    String getWebsite();
    String getIrcServer();
    String getDiscord();
    CompletableFuture<List<User>> getMembers();
    // other methods
}
  • User Interface: Refined with a focus on role management and user information, including methods like getRoles() and getUsername().
public interface User {
    List<String> getRoles();
    String getUsername();
    // other methods
}

Bug Fixes

Deprecated Methods

  • Removal of Deprecated Methods: Removed the deprecated retrieveFollowingGroupsOLD() method, ensuring that only the updated, more efficient methods are used within the codebase.

Entity Relationship Management

  • Improved Relationship Map Handling: Enhanced the handling of relationship maps within entities such as MDList, Manga, and ScanlationGroup. This update ensures more accurate and efficient retrieval of related entities, improving overall performance and reliability.

Deprecated

Legacy JavaDexBuilder Methods

  • Deprecation of Legacy Methods: The previous implementation of JavaDexBuilder, which allowed direct setting of client credentials, is now deprecated. Users are advised to adopt the new ClientPersonalJavaDexBuilder for a more robust and flexible approach to building JavaDex instances.

Installation

Maven

<dependency>
    <groupId>dev.kurumidisciples</groupId>
    <artifactId>javadex</artifactId>
    <version>0.1.5.0.BETA.2</version>
</dependency>

Gradle

implementation 'dev.kurumidisciples:javadex:0.1.5.0.BETA.2'