Skip to content

Commit

Permalink
Merge #385
Browse files Browse the repository at this point in the history
385: replaced traditional getter setter with lombok getter setter r=alallema a=ghousek1

# Pull Request

## What does this PR do?
Fixes #<379>
[issue link] (#379)

## PR checklist
Please check if your PR fulfills the following requirements:
- [x] Does this PR fix an existing issue?
- [x] Have you read the contributing guidelines?
- [x] Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!


Co-authored-by: GhouseK1 <ghousek1@outlook.com>
  • Loading branch information
bors[bot] and ghousek1 authored May 16, 2022
2 parents d28e4ff + 60a5959 commit 04244fa
Show file tree
Hide file tree
Showing 21 changed files with 93 additions and 877 deletions.
21 changes: 3 additions & 18 deletions src/main/java/com/meilisearch/sdk/Config.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.meilisearch.sdk;

import lombok.Getter;

/** Meilisearch configuration */
@Getter
public class Config {
String hostUrl;
String apiKey;
Expand All @@ -25,24 +28,6 @@ public Config(String hostUrl, String apiKey) {
this.apiKey = apiKey;
}

/**
* Method for returning the hostUrl
*
* @return host URL string of the Meilisearch instance
*/
public String getHostUrl() {
return hostUrl;
}

/**
* Method for returning the apiKey
*
* @return API key String
*/
public String getApiKey() {
return apiKey;
}

/**
* Method for returning the concatenated Bearer header with apiKey
*
Expand Down
100 changes: 4 additions & 96 deletions src/main/java/com/meilisearch/sdk/Details.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.meilisearch.sdk;

import java.util.Map;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class Details {

public Details() {}
Expand All @@ -18,100 +22,4 @@ public Details() {}
protected String[] stopWords;
protected Map<String, String[]> synonyms;
protected String distinctAttribute;

public int getReceivedDocuments() {
return receivedDocuments;
}

public void setReceivedDocuments(int receivedDocuments) {
this.receivedDocuments = receivedDocuments;
}

public int getIndexedDocuments() {
return indexedDocuments;
}

public void setIndexedDocuments(int indexedDocuments) {
this.indexedDocuments = indexedDocuments;
}

public int getDeletedDocuments() {
return deletedDocuments;
}

public void setDeletedDocuments(int deletedDocuments) {
this.deletedDocuments = deletedDocuments;
}

public String getPrimaryKey() {
return primaryKey;
}

public void setPrimaryKey(String primaryKey) {
this.primaryKey = primaryKey;
}

public String[] getRankingRules() {
return rankingRules;
}

public void setRankingRules(String[] rankingRules) {
this.rankingRules = rankingRules;
}

public String[] getSearchableAttributes() {
return searchableAttributes;
}

public void setSearchableAttributes(String[] searchableAttributes) {
this.searchableAttributes = searchableAttributes;
}

public String[] getDisplayedAttributes() {
return displayedAttributes;
}

public void setDisplayedAttributes(String[] displayedAttributes) {
this.displayedAttributes = displayedAttributes;
}

public String[] getFilterableAttributes() {
return filterableAttributes;
}

public void setFilterableAttributes(String[] filterableAttributes) {
this.filterableAttributes = filterableAttributes;
}

public String[] getSortableAttributes() {
return sortableAttributes;
}

public void setSortableAttributes(String[] sortableAttributes) {
this.sortableAttributes = sortableAttributes;
}

public String[] getStopWords() {
return stopWords;
}

public void setStopWords(String[] stopWords) {
this.stopWords = stopWords;
}

public Map<String, String[]> getSynonyms() {
return synonyms;
}

public void setSynonyms(Map<String, String[]> synonyms) {
this.synonyms = synonyms;
}

public String getDistinctAttribute() {
return distinctAttribute;
}

public void setDistinctAttribute(String distinctAttribute) {
this.distinctAttribute = distinctAttribute;
}
}
9 changes: 5 additions & 4 deletions src/main/java/com/meilisearch/sdk/Dump.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import lombok.ToString;

/** Meilisearch dump */
@Getter
public class Dump {
@Getter private String status;
@Getter private String uid;
@Getter @ToString.Exclude private String startedAt;
@Getter @ToString.Exclude private String finishedAt;
private String status;
private String uid;
@ToString.Exclude private String startedAt;
@ToString.Exclude private String finishedAt;
}
20 changes: 2 additions & 18 deletions src/main/java/com/meilisearch/sdk/GenericServiceTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import com.meilisearch.sdk.http.request.HttpRequest;
import com.meilisearch.sdk.http.response.HttpResponse;
import com.meilisearch.sdk.json.JsonHandler;
import lombok.Getter;

@Getter
public class GenericServiceTemplate implements ServiceTemplate {
private final AbstractHttpClient client;
private final JsonHandler processor;
Expand All @@ -27,24 +29,6 @@ public GenericServiceTemplate(
this.requestFactory = requestFactory;
}

/** {@inheritDoc} */
@Override
public AbstractHttpClient getClient() {
return client;
}

/** {@inheritDoc} */
@Override
public JsonHandler getProcessor() {
return processor;
}

/** {@inheritDoc} */
@Override
public RequestFactory getRequestFactory() {
return requestFactory;
}

/** {@inheritDoc} */
@Override
@SuppressWarnings("unchecked")
Expand Down
113 changes: 9 additions & 104 deletions src/main/java/com/meilisearch/sdk/Key.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package com.meilisearch.sdk;

import com.google.gson.*;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;

/** MeiliSearch response for a Key */
@Getter
public class Key {
protected String description = null;
@Setter protected String description = null;
protected String key = "";
protected String[] actions = null;
protected String[] indexes = null;
protected Date expiresAt = null;
@Setter protected String[] actions = null;
@Setter protected String[] indexes = null;
@Setter protected Date expiresAt = null;
protected Date createdAt = null;
protected Date updatedAt = null;

Expand All @@ -27,103 +31,4 @@ public String toString() {
Gson gson = builder.serializeNulls().setDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").create();
return gson.toJson(this);
}

/**
* Method to return the Key value
*
* @return String containing the value of the Key
*/
public String getKey() {
return this.key;
}

/**
* Method to set the description of the key
*
* @param description A description for the key
*/
public void setDescription(String description) {
this.description = description;
}

/**
* Method to return the description of the Key
*
* @return String containing the description of the Key
*/
public String getDescription() {
return this.description;
}

/**
* Method to set the actions authorized by the key
*
* @param actions An array of API actions permitted for the key.
*/
public void setActions(String[] actions) {
this.actions = actions;
}

/**
* Method to return the actions authorized by the key
*
* @return String containing the actions authorized by the key
*/
public String[] getActions() {
return this.actions;
}

/**
* Method to set the indexes accessible by the Key
*
* @param indexes An array of indexes the key is authorized to act on
*/
public void setIndexes(String[] indexes) {
this.indexes = indexes;
}

/**
* Method to return the indexes accessible by the Key
*
* @return String value of the indexes accessible by the Key
*/
public String[] getIndexes() {
return this.indexes;
}

/**
* Method to set the time that the Key will expire
*
* @param expiredAt Date and time when the key will expire, represented in ISO 8601 format
*/
public void setExpiresAt(Date expiredAt) {
this.expiresAt = expiredAt;
}

/**
* Method to return the time that the Key will expire
*
* @return Date and time of expiration date of the Key
*/
public Date getExpiresAt() {
return this.expiresAt;
}

/**
* Method to return the time that the Key was created at
*
* @return Date and time of the Key when it was created
*/
public Date getCreatedAt() {
return this.createdAt;
}

/**
* Method to return the time that the Update was finished at
*
* @return Date and time of the Update when it was finished
*/
public Date getUpdatedAt() {
return this.updatedAt;
}
}
12 changes: 2 additions & 10 deletions src/main/java/com/meilisearch/sdk/Result.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.meilisearch.sdk;

import com.google.gson.Gson;
import lombok.Getter;

/** MeiliSearch response for a Result */
public class Result<T> {
protected T[] results = null;
@Getter protected T[] results = null;

private static Gson gsonUpdate = new Gson();

Expand All @@ -17,13 +18,4 @@ public class Result<T> {
public String toString() {
return gsonUpdate.toJson(this);
}

/**
* Method to return the list contained in Result
*
* @return String containing the identifier of the Task
*/
public T[] getResults() {
return this.results;
}
}
Loading

0 comments on commit 04244fa

Please sign in to comment.