Skip to content

Commit

Permalink
Add toJsonNative method which doesn't run the isDrawable
Browse files Browse the repository at this point in the history
  • Loading branch information
AB-xdev committed Feb 16, 2024
1 parent 52ecdf9 commit 99163ab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.1.3
* Add ``toJsonNative`` method which doesn't run the ``isDrawable`` check #91

## 1.1.2
* ⚠️ GroupId changed from ``com.xdev-software`` to ``software.xdev``

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,8 @@ public T setOptions(final O options)
}

@Override
public String toJson()
public String toJsonNative()
{
if(!this.isDrawable())
{
throw new IllegalArgumentException("Chart is not drawable");
}

try
{
return this.objectWriter.writeValueAsString(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,20 @@ public interface Chart<SELF, O extends Options<O, ?>, D extends Data<D, ?>>
*
* @return json representation of {@code this} {@link Chart}
*/
String toJson();
String toJsonNative();

/**
* Same as {@link #toJsonNative()} but also check if the diagram {@link #isDrawable() is drawable}
* @see #toJson()
*/
default String toJson()
{
if(!this.isDrawable())
{
throw new IllegalArgumentException("Chart is not drawable");
}
return this.toJsonNative();
}

/**
* <p>
Expand Down

0 comments on commit 99163ab

Please sign in to comment.