-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mariana Azevedo
committed
Sep 17, 2020
1 parent
ab393d1
commit 5f3121b
Showing
10 changed files
with
232 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/main/java/io/github/mariazevedo88/financialjavaapi/util/BigDecimalConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.github.mariazevedo88.financialjavaapi.util; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import com.fasterxml.jackson.databind.node.ArrayNode; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import com.zero_x_baadf00d.partialize.converter.Converter; | ||
|
||
/** | ||
* Class that converts a given data in BigDecimal format to a JSON compatible format | ||
* | ||
* @author Mariana Azevedo | ||
* @since 17/09/2020 | ||
*/ | ||
public class BigDecimalConverter implements Converter<BigDecimal> { | ||
|
||
/** | ||
* @see com.zero_x_baadf00d.partialize.converter.Converter#convert(String, Object, ObjectNode) | ||
*/ | ||
@Override | ||
public void convert(String fieldName, BigDecimal data, ObjectNode node) { | ||
node.put(fieldName, data.doubleValue()); | ||
} | ||
|
||
/** | ||
* @see com.zero_x_baadf00d.partialize.converter.Converter#convert(String, Object, ArrayNode) | ||
*/ | ||
@Override | ||
public void convert(String fieldName, BigDecimal data, ArrayNode node) { | ||
node.add(data.doubleValue()); | ||
} | ||
|
||
/** | ||
* @see com.zero_x_baadf00d.partialize.converter.Converter#getManagedObjectClass() | ||
*/ | ||
@Override | ||
public Class<BigDecimal> getManagedObjectClass() { | ||
return BigDecimal.class; | ||
} | ||
|
||
} |
Oops, something went wrong.