Skip to content

Commit

Permalink
Merge pull request #21 from brenoepics/deepsource-transform-b5781119
Browse files Browse the repository at this point in the history
style: format code with Google Java Format
  • Loading branch information
brenoepics authored Jan 11, 2024
2 parents 3ded8b4 + e7f87e6 commit 8ba69d9
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 55 deletions.
9 changes: 4 additions & 5 deletions src/main/java/com/github/brenoepics/at4j/AzureApi.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.github.brenoepics.at4j;

import java.util.Collection;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

import com.github.brenoepics.at4j.azure.BaseURL;
import com.github.brenoepics.at4j.data.DetectedLanguage;
import com.github.brenoepics.at4j.azure.lang.Language;
import com.github.brenoepics.at4j.core.thread.ThreadPool;
import com.github.brenoepics.at4j.data.DetectedLanguage;
import com.github.brenoepics.at4j.data.request.AvailableLanguagesParams;
import com.github.brenoepics.at4j.data.request.DetectLanguageParams;
import com.github.brenoepics.at4j.data.request.TranslateParams;
import com.github.brenoepics.at4j.data.response.TranslationResponse;
import java.util.Collection;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

/**
* This class is the most important class of AT4J, as it contains the main methods for translating
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/com/github/brenoepics/at4j/core/AzureApiImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,26 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

import com.github.brenoepics.at4j.AzureApi;
import com.github.brenoepics.at4j.azure.BaseURL;
import com.github.brenoepics.at4j.azure.lang.Language;
import com.github.brenoepics.at4j.core.ratelimit.RateLimitManager;
import com.github.brenoepics.at4j.core.thread.ThreadPool;
import com.github.brenoepics.at4j.core.thread.ThreadPoolImpl;
import com.github.brenoepics.at4j.data.DetectedLanguage;
import com.github.brenoepics.at4j.data.Translation;
import okhttp3.OkHttpClient;
import com.github.brenoepics.at4j.azure.lang.Language;
import com.github.brenoepics.at4j.core.thread.ThreadPoolImpl;
import com.github.brenoepics.at4j.data.request.AvailableLanguagesParams;
import com.github.brenoepics.at4j.data.request.DetectLanguageParams;
import com.github.brenoepics.at4j.data.request.TranslateParams;
import com.github.brenoepics.at4j.data.response.TranslationResponse;
import com.github.brenoepics.at4j.util.rest.RestEndpoint;
import com.github.brenoepics.at4j.util.rest.RestMethod;
import com.github.brenoepics.at4j.util.rest.RestRequest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import okhttp3.OkHttpClient;

public class AzureApiImpl implements AzureApi {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.github.brenoepics.at4j.core.exceptions;

import java.util.Optional;

import com.github.brenoepics.at4j.util.rest.RestRequestInformation;
import com.github.brenoepics.at4j.util.rest.RestRequestResponseInformation;

import java.util.Optional;


/** This exception is always thrown whenever a request to azure failed. */
public class AzureException extends Exception {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.brenoepics.at4j.core.exceptions;

import com.github.brenoepics.at4j.util.rest.RestRequestResponseInformation;
import com.github.brenoepics.at4j.util.rest.RestRequestInformation;
import com.github.brenoepics.at4j.util.rest.RestRequestResponseInformation;

/** When we sent a bad request (HTTP response code 400). */
public class BadRequestException extends AzureException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.brenoepics.at4j.core.exceptions;

import com.github.brenoepics.at4j.util.rest.RestRequestResponseInformation;
import com.github.brenoepics.at4j.util.rest.RestRequestInformation;
import com.github.brenoepics.at4j.util.rest.RestRequestResponseInformation;

/** When something was not found (HTTP response code 404). */
public class NotFoundException extends BadRequestException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package com.github.brenoepics.at4j.core.ratelimit;

import com.github.brenoepics.at4j.core.AzureApiImpl;
import com.github.brenoepics.at4j.core.exceptions.AzureException;
import com.github.brenoepics.at4j.util.logging.LoggerUtil;
import com.github.brenoepics.at4j.util.rest.RestRequest;
import com.github.brenoepics.at4j.util.rest.RestRequestResponseInformationImpl;
import com.github.brenoepics.at4j.util.rest.RestRequestResult;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.function.Function;

import com.github.brenoepics.at4j.util.logging.LoggerUtil;
import okhttp3.Response;
import org.apache.logging.log4j.Logger;
import com.github.brenoepics.at4j.core.AzureApiImpl;
import com.github.brenoepics.at4j.core.exceptions.AzureException;
import com.github.brenoepics.at4j.util.rest.RestRequest;
import com.github.brenoepics.at4j.util.rest.RestRequestResponseInformationImpl;
import com.github.brenoepics.at4j.util.rest.RestRequestResult;

/** This class manages rate-limits and keeps track of them. */
public class RateLimitManager {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.github.brenoepics.at4j.core.ratelimit;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;

import com.github.brenoepics.at4j.AzureApi;
import com.github.brenoepics.at4j.core.AzureApiImpl;
import com.github.brenoepics.at4j.util.rest.RestEndpoint;
import com.github.brenoepics.at4j.util.rest.RestRequest;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;

public class RatelimitBucket {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.github.brenoepics.at4j.data.request;

import com.github.brenoepics.at4j.data.request.optional.LanguageScope;
import java.util.Collections;
import java.util.List;

import com.github.brenoepics.at4j.data.request.optional.LanguageScope;

public class AvailableLanguagesParams {
private List<LanguageScope> scope = List.of(LanguageScope.TRANSLATION);
private String sourceLanguage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.*;
import java.util.stream.Collectors;

import com.github.brenoepics.at4j.azure.lang.Language;
import com.github.brenoepics.at4j.data.request.optional.ProfanityAction;
import com.github.brenoepics.at4j.data.request.optional.ProfanityMarker;
import com.github.brenoepics.at4j.data.request.optional.TextType;
import java.util.*;
import java.util.stream.Collectors;

public class TranslateParams {
private String text;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.github.brenoepics.at4j.data.response;

import java.util.Collection;
import javax.annotation.Nullable;

import com.github.brenoepics.at4j.data.DetectedLanguage;
import com.github.brenoepics.at4j.data.Translation;
import java.util.Collection;
import javax.annotation.Nullable;

public class TranslationResponse {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.github.brenoepics.at4j.util.rest;

import java.util.Optional;

import com.github.brenoepics.at4j.azure.BaseURL;
import java.util.Optional;
import okhttp3.HttpUrl;

/** This enum contains all endpoints that we may use. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.github.brenoepics.at4j.util.rest;

import com.github.brenoepics.at4j.core.exceptions.AzureException;
import com.github.brenoepics.at4j.core.exceptions.AzureExceptionInstantiator;
import com.github.brenoepics.at4j.core.exceptions.BadRequestException;
import com.github.brenoepics.at4j.core.exceptions.NotFoundException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;

import com.github.brenoepics.at4j.core.exceptions.AzureException;
import com.github.brenoepics.at4j.core.exceptions.BadRequestException;
import com.github.brenoepics.at4j.core.exceptions.NotFoundException;
import com.github.brenoepics.at4j.core.exceptions.AzureExceptionInstantiator;

/**
* An enum with all rest request result codes as defined by <a
* href="https://learn.microsoft.com/en-us/azure/ai-services/translator/reference/v3-0-reference#errors">Azure</a>.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.github.brenoepics.at4j.util.rest;

import java.util.Optional;

import com.github.brenoepics.at4j.AzureApi;
import java.util.Optional;

/** Some information about a rest request response. */
public interface RestRequestResponseInformation {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.github.brenoepics.at4j.util.rest;

import java.util.Optional;

import com.github.brenoepics.at4j.AzureApi;
import java.util.Optional;

/** The implementation of {@link RestRequestResponseInformation}. */
public class RestRequestResponseInformationImpl implements RestRequestResponseInformation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.NullNode;
import com.github.brenoepics.at4j.util.logging.LoggerUtil;
import java.io.IOException;
import java.util.Optional;

import com.github.brenoepics.at4j.util.logging.LoggerUtil;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.apache.logging.log4j.Logger;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.brenoepics.at4j.util.rest;

import com.github.brenoepics.at4j.core.exceptions.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
Expand Down
11 changes: 5 additions & 6 deletions src/test/java/com/github/brenoepics/at4j/AzureApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

import static org.junit.Assert.*;

import com.github.brenoepics.at4j.azure.BaseURL;
import com.github.brenoepics.at4j.azure.lang.Language;
import com.github.brenoepics.at4j.data.request.AvailableLanguagesParams;
import com.github.brenoepics.at4j.data.request.TranslateParams;
import com.github.brenoepics.at4j.data.response.TranslationResponse;
import java.util.Collection;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;

import com.github.brenoepics.at4j.azure.BaseURL;
import okhttp3.OkHttpClient;
import org.junit.Test;
import com.github.brenoepics.at4j.azure.lang.Language;
import com.github.brenoepics.at4j.data.request.AvailableLanguagesParams;
import com.github.brenoepics.at4j.data.request.TranslateParams;
import com.github.brenoepics.at4j.data.response.TranslationResponse;

public class AzureApiTest {

Expand Down

0 comments on commit 8ba69d9

Please sign in to comment.