Skip to content

Commit

Permalink
Merge pull request #20 from trydofor/develop
Browse files Browse the repository at this point in the history
improve coverage, fix bug, remove useless
  • Loading branch information
trydofor authored Jan 29, 2024
2 parents cbcbeb5 + 2b0b89b commit ce6ce93
Show file tree
Hide file tree
Showing 61 changed files with 2,404 additions and 335 deletions.
19 changes: 11 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Release-To-OssRh
run-name: Deploy ${{github.event.release.tag_name}} to Sonatype by @${{ github.actor }}
run-name: Release ${{github.ref_name}} by @${{ github.event_name }}

on:
workflow_dispatch:
Expand All @@ -16,7 +16,7 @@ on:
required: false
testVerbose:
description: 'test output verbose'
default: true
default: false
type: boolean
required: false
deployOssrh:
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
## chache asdf/, m2/repository
- name: Cache Sdk & Repo
id: cache-sdk-repo
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.asdf/
Expand All @@ -53,7 +53,7 @@ jobs:

## install jdk and maven
- name: Install asdf & tools
uses: asdf-vm/actions/install@v2
uses: asdf-vm/actions/install@v3
with:
skip_install: ${{steps.cache-sdk-repo.outputs.cache-hit == 'true'}}

Expand All @@ -76,6 +76,9 @@ jobs:
echo $_ver
echo "WINGS_VERSION=$_ver" >> "$GITHUB_OUTPUT"
echo "MVN_COVERAGE=${{ inputs.testCoverReport || github.event_name == 'release' }}" >> "$GITHUB_OUTPUT"
echo "MVN_DEPLOYRH=${{ inputs.deployOssrh || github.event_name == 'release' }}" >> "$GITHUB_OUTPUT"
mvn -v
git --no-pager log --graph -10 --pretty=format:'%H - %ai %d %s'
Expand All @@ -95,26 +98,26 @@ jobs:
## report if not release
- name: Test Coverage ${{ steps.settings.outputs.WINGS_VERSION }} ${{ steps.settings.outputs.GIT_BRANCH }}
if: inputs.testCoverReport
if: steps.settings.outputs.MVN_COVERAGE
run: >
mvn
-P test
-P coverage
-Dmaven.test.failure.ignore=${{ inputs.testFailureIgnore }}
-DrepoToken=${{ secrets.COVERALLS_REPO_TOKEN }}
clean test jacoco:report coveralls:report
env:
JAVA_HOME: ${{ steps.settings.outputs.JAVA_HOME }}
## import gpp private key
- name: Import GPG key
if: inputs.deployOssrh
if: steps.settings.outputs.MVN_DEPLOYRH
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.MVN_GPG_SKEY }}
passphrase: ${{ secrets.MVN_GPG_PASS }}

## maven deploy
- name: Deploy ${{ steps.settings.outputs.WINGS_VERSION }} ${{ steps.settings.outputs.GIT_BRANCH }}
if: inputs.deployOssrh
if: steps.settings.outputs.MVN_DEPLOYRH
run: >
mvn
-P ossrh
Expand Down
48 changes: 39 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
<profiles>
<profile>
<!-- -DrepoToken=${{ secrets.COVERALLS_REPO_TOKEN }} -->
<id>test</id>
<id>coverage</id>
<properties>
<maven.test.skip>false</maven.test.skip>
</properties>
Expand All @@ -280,16 +280,46 @@
<version>0.8.11</version>
<configuration>
<excludes>
<exclude>**/best/**</exclude>
<exclude>**/stat/**</exclude>
<exclude>**/flow/**</exclude>
<exclude>**/img/**</exclude>
<!-- mark or assert -->
<exclude>**/best/Assert*</exclude>
<exclude>**/best/Dummy*</exclude>
<exclude>**/best/Param*</exclude>
<exclude>**/best/Typed*</exclude>
<!-- data struct -->
<exclude>**/data/DataResult.*</exclude>
<exclude>**/data/Null*</exclude>
<exclude>**/data/Q*</exclude>
<exclude>**/data/R*</exclude>
<exclude>**/data/U*</exclude>
<exclude>**/*Assert.*</exclude>
<exclude>**/data/Q.*</exclude>
<exclude>**/data/Q$*</exclude>
<exclude>**/data/R.*</exclude>
<exclude>**/data/R$*</exclude>
<exclude>**/data/U.*</exclude>
<exclude>**/data/U$*</exclude>
<!-- exception thrown -->
<exclude>**/flow/FlowBreak.*</exclude>
<exclude>**/evil/*Attention.*</exclude>
<!-- stat manually checked -->
<exclude>**/stat/GitStat*</exclude>
<exclude>**/stat/LogStat*</exclude>
<!-- image manually checked -->
<exclude>**/img/ImageIoFix*</exclude>
<exclude>**/img/StreamJpg*</exclude>
<exclude>**/img/Watermark*</exclude>
<exclude>**/img/ZoomRotateCrop*</exclude>
<!-- aware interface -->
<exclude>**/i18n/*Aware.*</exclude>
<!-- simple or manully checked -->
<exclude>**/io/CompatibleObjectStream*</exclude>
<exclude>**/io/DirHasher*</exclude>
<exclude>**/io/Exec*</exclude>
<exclude>**/io/NonCloseStream*</exclude>
<exclude>**/io/Zipper*</exclude>
<!-- trusted ssl invoke -->
<exclude>**/netx/SslTrustAll*</exclude>
<exclude>**/netx/SslVersion*</exclude>
<!-- exception only mark -->
<exclude>**/*Exception.*</exclude>
<exclude>**/*Enum.*</exclude>
<!-- just for fun -->
<exclude>**/WhoAmI.*</exclude>
</excludes>
</configuration>
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/pro/fessional/mirana/cast/BoxedCastUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ else if (obj instanceof byte[]) {
else if (obj instanceof char[]) {
vs = BoxedCastUtil.list((char[]) obj);
}
else if (obj instanceof short[]) {
vs = BoxedCastUtil.list((short[]) obj);
}
else if (obj instanceof int[]) {
vs = BoxedCastUtil.list((int[]) obj);
}
Expand All @@ -297,6 +300,9 @@ else if (obj instanceof float[]) {
else if (obj instanceof double[]) {
vs = BoxedCastUtil.list((double[]) obj);
}
else if (obj instanceof List) {
vs = (List<?>) obj;
}
else if (obj instanceof Collection) {
vs = new ArrayList<>((Collection<?>) obj);
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/pro/fessional/mirana/cast/StringCastUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public static boolean asTrue(@Nullable String str) {
}

/**
* parse case-insensitive `null`, `empty`, `blank` and `false,f,no,n` to false
* Note, no pass-through relationship with asTrue.
* parse case-insensitive `null`, `empty`, `blank` and `false,f,no,n` to false (BUT return true)
* NOTE1, no pass-through relationship with asTrue.
* NOTE2, return true if asFalse, e.g. "false".equalsIgnoreCase(str)
*/
public static boolean asFalse(@Nullable String str) {
if (str == null) return true;
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/pro/fessional/mirana/data/Arr.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class Arr {

@SafeVarargs
public static <T> T[] of(T... ts) {
public static <T> T[] obj(T... ts) {
return ts;
}

Expand Down Expand Up @@ -55,7 +55,7 @@ public static boolean[] set(boolean[] arr, int idx, boolean v) {
return arr;
}
else {
boolean[] tmp = new boolean[arr.length * 2];
boolean[] tmp = new boolean[Math.max(idx, arr.length) + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand All @@ -69,7 +69,7 @@ public static byte[] set(byte[] arr, int idx, byte v) {
return arr;
}
else {
byte[] tmp = new byte[arr.length * 2];
byte[] tmp = new byte[Math.max(idx, arr.length) + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand All @@ -83,7 +83,7 @@ public static short[] set(short[] arr, int idx, short v) {
return arr;
}
else {
short[] tmp = new short[arr.length * 2];
short[] tmp = new short[Math.max(idx, arr.length) + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand All @@ -97,7 +97,7 @@ public static char[] set(char[] arr, int idx, char v) {
return arr;
}
else {
char[] tmp = new char[arr.length * 2];
char[] tmp = new char[Math.max(idx, arr.length) + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand All @@ -111,7 +111,7 @@ public static int[] set(int[] arr, int idx, int v) {
return arr;
}
else {
int[] tmp = new int[arr.length * 2];
int[] tmp = new int[Math.max(idx, arr.length) + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand All @@ -125,7 +125,7 @@ public static long[] set(long[] arr, int idx, long v) {
return arr;
}
else {
long[] tmp = new long[arr.length * 2];
long[] tmp = new long[Math.max(idx, arr.length) + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand All @@ -139,7 +139,7 @@ public static float[] set(float[] arr, int idx, float v) {
return arr;
}
else {
float[] tmp = new float[arr.length * 2];
float[] tmp = new float[Math.max(idx, arr.length) + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand All @@ -153,7 +153,7 @@ public static double[] set(double[] arr, int idx, double v) {
return arr;
}
else {
double[] tmp = new double[arr.length * 2];
double[] tmp = new double[Math.max(idx, arr.length) + 1];
System.arraycopy(arr, 0, tmp, 0, arr.length);
tmp[idx] = v;
return tmp;
Expand Down
19 changes: 6 additions & 13 deletions src/main/java/pro/fessional/mirana/data/Diff.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static class V<E> {
public V() {
}

public V(E v1, E v2) {
private V(E v1, E v2) {
this.v1 = v1;
this.v2 = v2;
}
Expand Down Expand Up @@ -75,16 +75,12 @@ public boolean onlyV2() {
public boolean v1EqV2() {
return Objects.equals(v1, v2);
}
}

public static <T> V<T> of(T t1, T t2) {
return new V<>(t1, t2);
}

public static <K, T> void diff(Map<K, V<?>> map, K key, T t1, T t2) {
if (!Objects.equals(t1, t2)) {
map.put(key, new V<>(t1, t2));
}
}
@NotNull
public static <T> V<T> v(T t1, T t2) {
return new V<>(t1, t2);
}

/**
Expand Down Expand Up @@ -112,10 +108,7 @@ public static <K> LinkedHashMap<K, V<Object>> of(@Nullable Map<? extends K, ?> m
result.put(k, v);
}
else {
final Object v2 = en.getValue();
if (!Objects.equals(vs.v1, v2)) {
vs.v2 = v2;
}
vs.v2 = en.getValue();
}
}

Expand Down
14 changes: 14 additions & 0 deletions src/main/java/pro/fessional/mirana/evil/TweakingContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ public void initDefault(Supplier<T> value) {
defaultValue.set(value);
}

/**
* init the default value
*/
public void initGlobal(T value) {
tweakGlobal(value);
}

/**
* init the default value
*/
public void initGlobal(Supplier<T> value) {
tweakGlobal(value);
}

/**
* init thread value
*/
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/pro/fessional/mirana/i18n/I18nString.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* String can be used as i18n template,
* * code - template id
* * args - template arguments
* * hint - default text or template
* * i18n - i18n text
* * hint - default text or template, not in hash and equals
* * i18n - i18n text, not in hash and equals
* </pre>
*
* @author trydofor
Expand All @@ -28,7 +28,7 @@ public class I18nString implements I18nAware {

private final String code;
private final Object[] args;
private final String hint;
private String hint;
private transient String i18n = null;

public I18nString(String code) {
Expand Down Expand Up @@ -65,6 +65,12 @@ public String getI18n() {
return i18n;
}

@Contract("_ -> this")
public I18nString setHint(String hint) {
this.hint = hint == null ? "" : hint;;
return this;
}

@Contract("_ -> this")
public I18nString setI18n(String i18n) {
this.i18n = i18n;
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/pro/fessional/mirana/i18n/LocaleResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import java.util.Locale;

/**
* Supports the underscore(en_US) and the kebab(en-US) naming
* Supports the underscore(en_US) and the kebab(en-US) naming,
* return Locale.getDefault() if not found.
*
* @author trydofor
* @since 2019-07-01
Expand All @@ -16,14 +17,18 @@ protected LocaleResolver() {

@NotNull
public static Locale locale(@NotNull String tag) {
return locale(tag, Locale.getDefault());
}

@NotNull
public static Locale locale(@NotNull String tag, @NotNull Locale elz) {
if (tag.indexOf('_') >= 0) {
tag = tag.replace('_', '-');
}


Locale locale = Locale.forLanguageTag(tag);
if (locale.getLanguage().isEmpty()) {
return Locale.getDefault();
return elz;
}

return locale;
Expand Down
Loading

0 comments on commit ce6ce93

Please sign in to comment.