Skip to content

Commit 99163ab

Browse files
committed
Add toJsonNative method which doesn't run the isDrawable
#91
1 parent 52ecdf9 commit 99163ab

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 1.1.3
2+
* Add ``toJsonNative`` method which doesn't run the ``isDrawable`` check #91
3+
14
## 1.1.2
25
* ⚠️ GroupId changed from ``com.xdev-software`` to ``software.xdev``
36

chartjs-java-model/src/main/java/software/xdev/chartjs/model/charts/AbstractChart.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,8 @@ public T setOptions(final O options)
8585
}
8686

8787
@Override
88-
public String toJson()
88+
public String toJsonNative()
8989
{
90-
if(!this.isDrawable())
91-
{
92-
throw new IllegalArgumentException("Chart is not drawable");
93-
}
94-
9590
try
9691
{
9792
return this.objectWriter.writeValueAsString(this);

chartjs-java-model/src/main/java/software/xdev/chartjs/model/charts/Chart.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,20 @@ public interface Chart<SELF, O extends Options<O, ?>, D extends Data<D, ?>>
3737
*
3838
* @return json representation of {@code this} {@link Chart}
3939
*/
40-
String toJson();
40+
String toJsonNative();
41+
42+
/**
43+
* Same as {@link #toJsonNative()} but also check if the diagram {@link #isDrawable() is drawable}
44+
* @see #toJson()
45+
*/
46+
default String toJson()
47+
{
48+
if(!this.isDrawable())
49+
{
50+
throw new IllegalArgumentException("Chart is not drawable");
51+
}
52+
return this.toJsonNative();
53+
}
4154

4255
/**
4356
* <p>

0 commit comments

Comments
 (0)