Skip to content

Commit

Permalink
Add java module system compliance (#22)
Browse files Browse the repository at this point in the history
* upgraded to java 11
* moved/changed packages so every module now has a distinct 'parent' package
* set new version to be 2.0.0
* reworked java-chartjs-data and java-charts-serialization to be full jigsaw modules
* java-chartjs-wicket can't be a module because not all dependencies are jigsaw-compliant but has an automatic module name at least
  • Loading branch information
haster committed Jun 22, 2019
1 parent 49205b6 commit f47d4bf
Show file tree
Hide file tree
Showing 30 changed files with 232 additions and 175 deletions.
6 changes: 4 additions & 2 deletions data/pom.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>nl.crashdata.java-chartjs</groupId>
<artifactId>java-chartjs</artifactId>
<version>1.0.1-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
12 changes: 12 additions & 0 deletions data/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module nl.crashdata.chartjs.data
{
exports nl.crashdata.chartjs.data;

exports nl.crashdata.chartjs.data.colors;

exports nl.crashdata.chartjs.data.simple;

exports nl.crashdata.chartjs.data.simple.builder;

requires com.fasterxml.jackson.annotation;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;
import nl.crashdata.chartjs.colors.ChartJsRGBAColor;
import nl.crashdata.chartjs.data.colors.ChartJsRGBAColor;

/**
* Represents the configuration of one dataset for a chart. In other words, this represents the data
Expand Down
89 changes: 57 additions & 32 deletions data/src/main/java/nl/crashdata/chartjs/data/ChartJsFill.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
package nl.crashdata.chartjs.data;

import com.fasterxml.jackson.annotation.JsonValue;
import static nl.crashdata.chartjs.data.ChartJsFillMode.*;

import com.fasterxml.jackson.annotation.JsonValue;

/**
* A value object to represent the fill-configuration for a chart, ie. how to fill the area under
* a line or radar graph.
*
* Gets serialised to a javascript string value. Corresponds to the {@code config.data.datasets[].fill} property.
*
* A value object to represent the fill-configuration for a chart, ie. how to fill the area under a
* line or radar graph.
*
* Gets serialised to a javascript string value. Corresponds to the
* {@code config.data.datasets[].fill} property.
*
* @author haster
*
*/
public final class ChartJsFill {

public final class ChartJsFill
{

public static final ChartJsFill DISABLED = new ChartJsFill();
static {
static
{
DISABLED.mode = ChartJsFillMode.DISABLED;
DISABLED.boundary = null;
DISABLED.datasetIndex = null;
Expand All @@ -26,34 +30,45 @@ public final class ChartJsFill {
private ChartJsBoundaryType boundary;

private Integer datasetIndex;

private ChartJsFill() {}


private ChartJsFill()
{
}

/**
* Sets the fill property to a value indicating it is disabled (ie, don't fill)
*/
public static ChartJsFill disabled() {
public static ChartJsFill disabled()
{
return DISABLED;
}

/**
* Sets the fill property to a value indicating fill to a boundary.
* @param boundary The boundary to which the area needs to be filled.
*
* @param boundary
* The boundary to which the area needs to be filled.
*/
public static ChartJsFill boundary(ChartJsBoundaryType boundary) {
public static ChartJsFill boundary(ChartJsBoundaryType boundary)
{
ChartJsFill fill = new ChartJsFill();
fill.mode = BOUNDARY;
fill.boundary = boundary;
fill.datasetIndex = null;
return fill;
}

/**
* Sets the fill property to a value indicating fill to another dataset.
* @param datasetIndex the relative index of the dataset to which the area should be filled. Must be nonzero.
*
* @param datasetIndex
* the relative index of the dataset to which the area should be filled. Must be
* nonzero.
*/
public static ChartJsFill relativeIndex(int datasetIndex) {
if (datasetIndex == 0) {
public static ChartJsFill relativeIndex(int datasetIndex)
{
if (datasetIndex == 0)
{
throw new IllegalArgumentException("Relative dataset index can not be 0!");
}
ChartJsFill fill = new ChartJsFill();
Expand All @@ -62,16 +77,22 @@ public static ChartJsFill relativeIndex(int datasetIndex) {
fill.datasetIndex = datasetIndex;
return fill;
}

/**
* Sets the fill property to a value indicating fill to another dataset.
* @param datasetIndex the absolute index of the dataset to which the area should be filled. Must be strictly positive.
*
* @param datasetIndex
* the absolute index of the dataset to which the area should be filled. Must be
* strictly positive.
*/
public static ChartJsFill absoluteIndex(int datasetIndex) {
if (datasetIndex == 0) {
public static ChartJsFill absoluteIndex(int datasetIndex)
{
if (datasetIndex == 0)
{
throw new IllegalArgumentException("Absolute dataset index can not be 0!");
}
if (datasetIndex < 0) {
if (datasetIndex < 0)
{
throw new IllegalArgumentException("Absolute dataset index can not negative!");
}
ChartJsFill fill = new ChartJsFill();
Expand All @@ -82,8 +103,10 @@ public static ChartJsFill absoluteIndex(int datasetIndex) {
}

@JsonValue
String toJsonString() {
switch (mode) {
public String toJsonString()
{
switch (mode)
{
case ABSOLUTE_DATASET_INDEX:
return String.format("%d", datasetIndex);
case RELATIVE_DATASET_INDEX:
Expand All @@ -96,17 +119,19 @@ String toJsonString() {
throw new IllegalStateException();
}
}

private static String toStringValue(ChartJsBoundaryType boundary) {
switch (boundary) {

private static String toStringValue(ChartJsBoundaryType boundary)
{
switch (boundary)
{
case START:
return "start";
case END:
return "end";
case ORIGIN:
return "origin";
default:
throw new IllegalArgumentException("Unknown ChartJsBoundaryType: "+boundary);
default:
throw new IllegalArgumentException("Unknown ChartJsBoundaryType: " + boundary);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.List;

import com.fasterxml.jackson.annotation.JsonProperty;
import nl.crashdata.chartjs.colors.ChartJsRGBAColor;
import nl.crashdata.chartjs.data.colors.ChartJsRGBAColor;

/**
* Represents the title-configuration for a chart.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonProperty;
import nl.crashdata.chartjs.colors.ChartJsRGBAColor;
import nl.crashdata.chartjs.data.colors.ChartJsRGBAColor;

/**
* Represents the tooltip-configuration for a chart, ie. when to show a tooltip (and what to show in
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package nl.crashdata.chartjs.colors;
package nl.crashdata.chartjs.data.colors;

import java.io.Serializable;
import java.util.Locale;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import java.io.Serializable;
import java.util.List;

import nl.crashdata.chartjs.colors.ChartJsRGBAColor;
import nl.crashdata.chartjs.data.ChartJsDataset;
import nl.crashdata.chartjs.data.ChartJsFill;
import nl.crashdata.chartjs.data.colors.ChartJsRGBAColor;

public class SimpleChartJsDataset<V extends Serializable> implements ChartJsDataset<V>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import java.util.List;

import nl.crashdata.chartjs.colors.ChartJsRGBAColor;
import nl.crashdata.chartjs.data.ChartJsPosition;
import nl.crashdata.chartjs.data.ChartJsTitleConfig;
import nl.crashdata.chartjs.data.colors.ChartJsRGBAColor;

public class SimpleChartJsTitleConfig implements ChartJsTitleConfig
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package nl.crashdata.chartjs.data.simple;

import nl.crashdata.chartjs.colors.ChartJsRGBAColor;
import nl.crashdata.chartjs.data.ChartJsInteractionMode;
import nl.crashdata.chartjs.data.ChartJsTooltipConfig;
import nl.crashdata.chartjs.data.ChartJsTooltipPositioning;
import nl.crashdata.chartjs.data.colors.ChartJsRGBAColor;

public class SimpleChartJsTooltipConfig implements ChartJsTooltipConfig
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import java.util.function.Function;
import java.util.stream.Collectors;

import nl.crashdata.chartjs.colors.ChartJsRGBAColor;
import nl.crashdata.chartjs.data.ChartJsFill;
import nl.crashdata.chartjs.data.colors.ChartJsRGBAColor;
import nl.crashdata.chartjs.data.simple.SimpleChartJsDataset;

public class SimpleChartJsDatasetBuilder<E extends Serializable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import java.util.ArrayList;
import java.util.List;

import nl.crashdata.chartjs.colors.ChartJsRGBAColor;
import nl.crashdata.chartjs.data.ChartJsPosition;
import nl.crashdata.chartjs.data.ChartJsTitleConfig;
import nl.crashdata.chartjs.data.colors.ChartJsRGBAColor;
import nl.crashdata.chartjs.data.simple.SimpleChartJsTitleConfig;

public class SimpleChartJsTitleConfigBuilder implements SimpleChartJsBuilder<ChartJsTitleConfig>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package nl.crashdata.chartjs.data.simple.builder;

import nl.crashdata.chartjs.colors.ChartJsRGBAColor;
import nl.crashdata.chartjs.data.ChartJsInteractionMode;
import nl.crashdata.chartjs.data.ChartJsTooltipPositioning;
import nl.crashdata.chartjs.data.colors.ChartJsRGBAColor;
import nl.crashdata.chartjs.data.simple.SimpleChartJsTooltipConfig;

public class SimpleChartJsTooltipConfigBuilder
Expand Down
22 changes: 2 additions & 20 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<parent>
<groupId>nl.crashdata.crashdata-parent</groupId>
<artifactId>crashdata-parent</artifactId>
<version>1.21</version>
<version>1.25</version>
</parent>

<groupId>nl.crashdata.java-chartjs</groupId>
<artifactId>java-chartjs</artifactId>
<version>1.0.1-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>java-chartjs parent</name>
Expand Down Expand Up @@ -58,22 +58,4 @@
</dependency>
</dependencies>
</dependencyManagement>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<inherited>true</inherited>
<configuration>
<source>8</source>
<encoding>UTF-8</encoding>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
10 changes: 3 additions & 7 deletions serialization/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>nl.crashdata.java-chartjs</groupId>
<artifactId>java-chartjs</artifactId>
<version>1.0.1-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>java-chartjs-serialization</artifactId>
Expand All @@ -21,6 +21,7 @@
<dependency>
<groupId>nl.crashdata.java-chartjs</groupId>
<artifactId>java-chartjs-data</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand All @@ -37,10 +38,5 @@
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
</project>
12 changes: 12 additions & 0 deletions serialization/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module nl.crashdata.chartjs.serialization
{
exports nl.crashdata.chartjs.serialization;

requires com.fasterxml.jackson.annotation;

requires com.fasterxml.jackson.core;

requires transitive com.fasterxml.jackson.databind;

requires com.fasterxml.jackson.datatype.jsr310;
}
Loading

0 comments on commit f47d4bf

Please sign in to comment.