Skip to content

Commit 50da70e

Browse files
authored
refactor: refactor into a multi-module architecture (#706)
* refactor: split into multiple maven modules * chore: update maven build and test modules * build: remove spotless check execution * build: restore surefire.jdk9plus.args * fix: resolve conflict * Merge remote-tracking branch 'origin/main' into maven-multi-module * fix: resolve conflict
1 parent dbbc7e6 commit 50da70e

File tree

779 files changed

+20876
-302
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

779 files changed

+20876
-302
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ jobs:
8282
restore-keys: |
8383
${{ runner.os }}-m2
8484
- name: Test with Maven
85-
run: ./mvnw test -B -Dmaven.test.skip=false -pl fesod
85+
run: ./mvnw test -B -Dmaven.test.skip=false -pl fesod-common,fesod-sheet
8686
- name: Publish Unit Test Results
8787
uses: EnricoMi/publish-unit-test-result-action@v2
8888
if: (!cancelled())
8989
with:
9090
files: "**/target/surefire-reports/*.xml"
9191
- name: Maven Build
92-
run: ./mvnw install -B -V -pl fesod
92+
run: ./mvnw install -B -V -pl fesod-common,fesod-sheet
9393
- name: Java Doc
9494
run: ./mvnw javadoc:javadoc

fesod-bom/pom.xml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
21+
-->
22+
<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">
23+
<modelVersion>4.0.0</modelVersion>
24+
25+
<parent>
26+
<groupId>org.apache.fesod</groupId>
27+
<artifactId>fesod-parent</artifactId>
28+
<version>${revision}</version>
29+
</parent>
30+
31+
<artifactId>fesod-bom</artifactId>
32+
<packaging>pom</packaging>
33+
<name>Fesod Bom</name>
34+
35+
<dependencyManagement>
36+
<dependencies>
37+
<dependency>
38+
<groupId>org.apache.fesod</groupId>
39+
<artifactId>fesod-common</artifactId>
40+
<version>${project.version}</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.apache.fesod</groupId>
44+
<artifactId>fesod-sheet</artifactId>
45+
<version>${project.version}</version>
46+
</dependency>
47+
</dependencies>
48+
</dependencyManagement>
49+
</project>

fesod-common/pom.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
21+
-->
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<parent>
27+
<groupId>org.apache.fesod</groupId>
28+
<artifactId>fesod-parent</artifactId>
29+
<version>${revision}</version>
30+
</parent>
31+
32+
<artifactId>fesod-common</artifactId>
33+
<packaging>jar</packaging>
34+
<name>Fesod Common</name>
35+
36+
<dependencies>
37+
</dependencies>
38+
</project>
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.fesod.common.util;
21+
22+
public class BooleanUtils {
23+
24+
private static final String TRUE_NUMBER = "1";
25+
26+
private BooleanUtils() {}
27+
28+
/**
29+
* String to boolean
30+
*
31+
* @param str
32+
* @return
33+
*/
34+
public static Boolean valueOf(String str) {
35+
if (TRUE_NUMBER.equals(str)) {
36+
return Boolean.TRUE;
37+
} else {
38+
return Boolean.FALSE;
39+
}
40+
}
41+
42+
// boolean Boolean methods
43+
// -----------------------------------------------------------------------
44+
45+
/**
46+
* <p>Checks if a {@code Boolean} value is {@code true},
47+
* handling {@code null} by returning {@code false}.</p>
48+
*
49+
* <pre>
50+
* BooleanUtils.isTrue(Boolean.TRUE) = true
51+
* BooleanUtils.isTrue(Boolean.FALSE) = false
52+
* BooleanUtils.isTrue(null) = false
53+
* </pre>
54+
*
55+
* @param bool the boolean to check, null returns {@code false}
56+
* @return {@code true} only if the input is non-null and true
57+
* @since 2.1
58+
*/
59+
public static boolean isTrue(final Boolean bool) {
60+
return Boolean.TRUE.equals(bool);
61+
}
62+
63+
/**
64+
* <p>Checks if a {@code Boolean} value is <i>not</i> {@code true},
65+
* handling {@code null} by returning {@code true}.</p>
66+
*
67+
* <pre>
68+
* BooleanUtils.isNotTrue(Boolean.TRUE) = false
69+
* BooleanUtils.isNotTrue(Boolean.FALSE) = true
70+
* BooleanUtils.isNotTrue(null) = true
71+
* </pre>
72+
*
73+
* @param bool the boolean to check, null returns {@code true}
74+
* @return {@code true} if the input is null or false
75+
* @since 2.3
76+
*/
77+
public static boolean isNotTrue(final Boolean bool) {
78+
return !isTrue(bool);
79+
}
80+
81+
/**
82+
* <p>Checks if a {@code Boolean} value is {@code false},
83+
* handling {@code null} by returning {@code false}.</p>
84+
*
85+
* <pre>
86+
* BooleanUtils.isFalse(Boolean.TRUE) = false
87+
* BooleanUtils.isFalse(Boolean.FALSE) = true
88+
* BooleanUtils.isFalse(null) = false
89+
* </pre>
90+
*
91+
* @param bool the boolean to check, null returns {@code false}
92+
* @return {@code true} only if the input is non-null and false
93+
* @since 2.1
94+
*/
95+
public static boolean isFalse(final Boolean bool) {
96+
return Boolean.FALSE.equals(bool);
97+
}
98+
99+
/**
100+
* <p>Checks if a {@code Boolean} value is <i>not</i> {@code false},
101+
* handling {@code null} by returning {@code true}.</p>
102+
*
103+
* <pre>
104+
* BooleanUtils.isNotFalse(Boolean.TRUE) = true
105+
* BooleanUtils.isNotFalse(Boolean.FALSE) = false
106+
* BooleanUtils.isNotFalse(null) = true
107+
* </pre>
108+
*
109+
* @param bool the boolean to check, null returns {@code true}
110+
* @return {@code true} if the input is null or true
111+
* @since 2.3
112+
*/
113+
public static boolean isNotFalse(final Boolean bool) {
114+
return !isFalse(bool);
115+
}
116+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.fesod.common.util;
21+
22+
/**
23+
* Int utils
24+
*
25+
*
26+
**/
27+
public class IntUtils {
28+
private IntUtils() {}
29+
30+
/**
31+
* The largest power of two that can be represented as an {@code int}.
32+
*
33+
* @since 10.0
34+
*/
35+
public static final int MAX_POWER_OF_TWO = 1 << (Integer.SIZE - 2);
36+
37+
/**
38+
* Returns the {@code int} nearest in value to {@code value}.
39+
*
40+
* @param value any {@code long} value
41+
* @return the same value cast to {@code int} if it is in the range of the {@code int} type,
42+
* {@link Integer#MAX_VALUE} if it is too large, or {@link Integer#MIN_VALUE} if it is too
43+
* small
44+
*/
45+
public static int saturatedCast(long value) {
46+
if (value > Integer.MAX_VALUE) {
47+
return Integer.MAX_VALUE;
48+
}
49+
if (value < Integer.MIN_VALUE) {
50+
return Integer.MIN_VALUE;
51+
}
52+
return (int) value;
53+
}
54+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
package org.apache.fesod.common.util;
21+
22+
import java.io.ByteArrayOutputStream;
23+
import java.io.IOException;
24+
import java.io.InputStream;
25+
import java.io.OutputStream;
26+
27+
/**
28+
* IO Utils
29+
*
30+
*
31+
*/
32+
public class IoUtils {
33+
public static final int EOF = -1;
34+
/**
35+
* The default buffer size ({@value}) to use for
36+
*/
37+
private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
38+
39+
private IoUtils() {}
40+
41+
/**
42+
* Gets the contents of an InputStream as a byte[].
43+
*
44+
* @param input
45+
* @return
46+
* @throws IOException
47+
*/
48+
public static byte[] toByteArray(final InputStream input) throws IOException {
49+
final ByteArrayOutputStream output = new ByteArrayOutputStream();
50+
try {
51+
copy(input, output);
52+
return output.toByteArray();
53+
} finally {
54+
output.toByteArray();
55+
}
56+
}
57+
58+
/**
59+
* Gets the contents of an InputStream as a byte[].
60+
*
61+
* @param input
62+
* @param size
63+
* @return
64+
* @throws IOException
65+
*/
66+
public static byte[] toByteArray(final InputStream input, final int size) throws IOException {
67+
if (size < 0) {
68+
throw new IllegalArgumentException("Size must be equal or greater than zero: " + size);
69+
}
70+
if (size == 0) {
71+
return new byte[0];
72+
}
73+
final byte[] data = new byte[size];
74+
int offset = 0;
75+
int read;
76+
while (offset < size && (read = input.read(data, offset, size - offset)) != EOF) {
77+
offset += read;
78+
}
79+
if (offset != size) {
80+
throw new IOException("Unexpected read size. current: " + offset + ", expected: " + size);
81+
}
82+
return data;
83+
}
84+
85+
/**
86+
* Copies bytes
87+
*
88+
* @param input
89+
* @param output
90+
* @return
91+
* @throws IOException
92+
*/
93+
public static int copy(final InputStream input, final OutputStream output) throws IOException {
94+
long count = 0;
95+
int n;
96+
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
97+
while (EOF != (n = input.read(buffer))) {
98+
output.write(buffer, 0, n);
99+
count += n;
100+
}
101+
if (count > Integer.MAX_VALUE) {
102+
return -1;
103+
}
104+
return (int) count;
105+
}
106+
}

0 commit comments

Comments
 (0)