Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Onboard more model classes to Lombok #106

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import com.smartsheet.api.models.Attachment;
import com.smartsheet.api.models.CopyOrMoveRowDirective;
import com.smartsheet.api.models.CopyOrMoveRowResult;
import com.smartsheet.api.models.Error;
import com.smartsheet.api.models.PagedResult;
import com.smartsheet.api.models.Result;
import org.apache.http.client.methods.CloseableHttpResponse;
Expand Down Expand Up @@ -210,8 +211,7 @@ protected <T> T getResource(String path, Class<T> objectClass) throws Smartsheet
Util.throwIfNull(path, objectClass);

if (path.isEmpty()) {
com.smartsheet.api.models.Error error = new com.smartsheet.api.models.Error();
error.setMessage("An empty path was provided.");
Error error = Error.builder().message("An empty path was provided.").build();
throw new ResourceNotFoundException(error);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,10 +527,11 @@ private PartialRowUpdateResult doPartialRowOperation(
if (bulkItemResult.getFailedItems() != null) {
List<BulkRowFailedItem> failedItems = new ArrayList<>();
for (BulkItemFailure bulkItemFailure : bulkItemResult.getFailedItems()) {
BulkRowFailedItem bulkRowFailedItem = new BulkRowFailedItem();
bulkRowFailedItem.setError(bulkItemFailure.getError());
bulkRowFailedItem.setIndex(bulkItemFailure.getIndex());
bulkRowFailedItem.setRowId(bulkItemFailure.getRowId());
BulkRowFailedItem bulkRowFailedItem = BulkRowFailedItem.builder()
.error(bulkItemFailure.getError())
.index(bulkItemFailure.getIndex())
.rowId(bulkItemFailure.getRowId())
.build();
failedItems.add(bulkRowFailedItem);
}
result.setFailedItems(failedItems);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public com.smartsheet.api.models.Error deserialize(JsonParser jp, Deserializatio

ObjectMapper mapper = new ObjectMapper();

final com.smartsheet.api.models.Error error = new com.smartsheet.api.models.Error();
final com.smartsheet.api.models.Error error = com.smartsheet.api.models.Error.builder().build();

if (jp.getCurrentToken() == JsonToken.START_OBJECT) {
JsonNode node = jp.getCodec().readTree(jp);
Expand Down
88 changes: 11 additions & 77 deletions src/main/java/com/smartsheet/api/models/AutoNumberFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,23 @@

package com.smartsheet.api.models;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.jackson.Jacksonized;

/**
* Represents the AutoNumberFormat object. It describes how the the System Column type of "AUTO_NUMBER" is auto-generated
*
* @see <a href="https://smartsheet.redoc.ly/tag/commonObjects/#section/AutoNumberFormat-Object">Auto Number Format API Documentation</a>
* @see <a href="http://help.smartsheet.com/customer/portal/articles/1108408-auto-numbering">Auto Number Format Help</a>
*/
@Getter
@Setter
@ToString
@Jacksonized
@Builder
public class AutoNumberFormat {

/**
Expand All @@ -43,81 +54,4 @@ public class AutoNumberFormat {
* Represents the starting number.
*/
private Long startingNumber;

/**
* Gets the prefix.
*
* @return the prefix
*/
public String getPrefix() {
return prefix;
}

/**
* Sets the prefix. The prefix. Can include the date tokens {YY}, {YYYY}, {MM}, {DD}
*
* @param prefix the new prefix
*/
public AutoNumberFormat setPrefix(String prefix) {
this.prefix = prefix;
return this;
}

/**
* Gets the suffix.
*
* @return the suffix
*/
public String getSuffix() {
return suffix;
}

/**
* Sets the suffix.
*
* @param suffix the new suffix
*/
public AutoNumberFormat setSuffix(String suffix) {
this.suffix = suffix;
return this;
}

/**
* Gets the fill.
*
* @return the fill
*/
public String getFill() {
return fill;
}

/**
* Sets the fill. Must be 0 - 10 "0" characters. Indicates zero-padding
*
* @param fill the new fill
*/
public AutoNumberFormat setFill(String fill) {
this.fill = fill;
return this;
}

/**
* Gets the starting number.
*
* @return the starting number
*/
public Long getStartingNumber() {
return startingNumber;
}

/**
* Sets the starting number for the auto-id.
*
* @param startingNumber the new starting number
*/
public AutoNumberFormat setStartingNumber(Long startingNumber) {
this.startingNumber = startingNumber;
return this;
}

}
11 changes: 11 additions & 0 deletions src/main/java/com/smartsheet/api/models/BulkItemFailure.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@

package com.smartsheet.api.models;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;

@Getter
@Setter
@ToString
@Jacksonized
@SuperBuilder
public class BulkItemFailure extends BulkRowFailedItem {
// doing this just to create a more generic class name for bulk operations
}
49 changes: 12 additions & 37 deletions src/main/java/com/smartsheet/api/models/BulkRowFailedItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,22 @@

package com.smartsheet.api.models;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import lombok.extern.jackson.Jacksonized;

/**
* Created by kskeem on 3/1/16.
* The BulkRowFailedItem model
*/
@Getter
@Setter
@ToString
@Jacksonized
@SuperBuilder
public class BulkRowFailedItem {
private int index;
private Error error;
private Long rowId;

public int getIndex() {
return index;
}

/**
* Set the index
*/
public BulkRowFailedItem setIndex(int index) {
this.index = index;
return this;
}

public Error getError() {
return error;
}

/**
* Set the Error
*/
public BulkRowFailedItem setError(Error error) {
this.error = error;
return this;
}

public Long getRowId() {
return rowId;
}

/**
* Set the Row ID
*/
public BulkRowFailedItem setRowId(Long rowId) {
this.rowId = rowId;
return this;
}
}
88 changes: 11 additions & 77 deletions src/main/java/com/smartsheet/api/models/Error.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,20 @@

package com.smartsheet.api.models;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.jackson.Jacksonized;

/**
* Represents Error object.
*/
@Getter
@Setter
@ToString
@Jacksonized
@Builder
public class Error {
/**
* Represents the error detail.
Expand All @@ -39,81 +50,4 @@ public class Error {
* Reference ID
*/
private String refId;

/**
* Gets the error detail.
*
* @return the error detail
*/
public Object getDetail() {
return detail;
}

/**
* Sets the error detail.
*
* @param detail the error detail
*/
public Error setDetail(Object detail) {
this.detail = detail;
return this;
}

/**
* Gets the message.
*
* @return the message
*/
public String getMessage() {
return message;
}

/**
* Sets the message.
*
* @param message the new message
*/
public Error setMessage(String message) {
this.message = message;
return this;
}

/**
* Gets the error code.
*
* @return the error code
*/
public Integer getErrorCode() {
return errorCode;
}

/**
* Sets the error code.
*
* @param errorCode the new error code
*/
public Error setErrorCode(Integer errorCode) {
this.errorCode = errorCode;
return this;
}

/**
* Get the reference ID
*
* @return the refId
*/
public String getRefId() {
return refId;
}

/**
* Set the reference ID
*
* @param refId the reference ID
* @return the Error Object
*/
public Error setRefId(String refId) {
this.refId = refId;
return this;
}
}
33 changes: 14 additions & 19 deletions src/main/java/com/smartsheet/api/models/SortSpecifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,26 @@

package com.smartsheet.api.models;

import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.jackson.Jacksonized;

import java.util.List;

/**
* The SortSpecifier model.
*/
@Getter
@Setter
@ToString
@Jacksonized
@Builder
public class SortSpecifier {

/**
* An array of sort criterion
*/
private List<SortCriterion> sortCriteria;

/**
* Get the sort criteria
*
* @return the array of sort criteria
*/
public List<SortCriterion> getSortCriteria() {
return sortCriteria;
}

/**
* Set the sort criteria
*
* @param sortCriteria the array of sort criteria
*/
public SortSpecifier setSortCriteria(List<SortCriterion> sortCriteria) {
this.sortCriteria = sortCriteria;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ class AccessTokenExpiredExceptionTest {
@Test
void testAccessTokenExpiredException() {
try {
Error error = new Error();
error.setErrorCode(1);
error.setMessage("testing testing");
Error error = Error.builder()
.errorCode(1)
.message("testing testing")
.build();
throw new AccessTokenExpiredException(error);
} catch (AccessTokenExpiredException e) {
assertThat(e.getMessage()).isEqualTo("testing testing");
Expand Down
Loading
Loading