Skip to content

Commit

Permalink
Merge pull request #72 from yindz/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
yindz authored Apr 2, 2023
2 parents 5e09c2f + f01390d commit 34f0c6d
Show file tree
Hide file tree
Showing 5 changed files with 531 additions and 190 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.apifan.common</groupId>
<artifactId>common-random</artifactId>
<version>1.0.19</version>
<version>1.0.20</version>
<packaging>jar</packaging>
<name>common-random</name>
<description>An easy-to-use random data generator.</description>
Expand Down
56 changes: 56 additions & 0 deletions src/main/java/com/apifan/common/random/entity/GreekAlphabet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.apifan.common.random.entity;

/**
* 希腊字母
* 在数学/科学/工程领域中需要用到
*
* @author yin
* @since 1.0.20
*/
public class GreekAlphabet {

/**
* 大写形式
*/
private String upperCase;

/**
* 小写形式
*/
private String lowerCase;

/**
* 读音
*/
private String spell;

public GreekAlphabet(String upperCase, String lowerCase, String spell) {
this.upperCase = upperCase;
this.lowerCase = lowerCase;
this.spell = spell;
}

public String getUpperCase() {
return upperCase;
}

public void setUpperCase(String upperCase) {
this.upperCase = upperCase;
}

public String getLowerCase() {
return lowerCase;
}

public void setLowerCase(String lowerCase) {
this.lowerCase = lowerCase;
}

public String getSpell() {
return spell;
}

public void setSpell(String spell) {
this.spell = spell;
}
}
41 changes: 41 additions & 0 deletions src/main/java/com/apifan/common/random/source/LanguageSource.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.apifan.common.random.source;

import com.apifan.common.random.entity.GreekAlphabet;
import com.apifan.common.random.entity.Poem;
import com.apifan.common.random.util.JsonUtils;
import com.apifan.common.random.util.ResourceUtils;
Expand Down Expand Up @@ -82,6 +83,11 @@ public class LanguageSource {
*/
private static List<String> englishWordsList = Lists.newArrayList();

/**
* 希腊字母
*/
private static final List<GreekAlphabet> greekAlphabets = Lists.newArrayList();

private static final LanguageSource instance = new LanguageSource();

private LanguageSource() {
Expand All @@ -101,6 +107,31 @@ private LanguageSource() {
} catch (Exception e) {
logger.error("初始化数据异常", e);
}

greekAlphabets.add(new GreekAlphabet("Α", "α", "alpha"));
greekAlphabets.add(new GreekAlphabet("Β", "β", "beta"));
greekAlphabets.add(new GreekAlphabet("Γ", "γ", "gamma"));
greekAlphabets.add(new GreekAlphabet("Δ", "δ", "delta"));
greekAlphabets.add(new GreekAlphabet("Ε", "ε", "epsilon"));
greekAlphabets.add(new GreekAlphabet("Ζ", "ζ", "zeta"));
greekAlphabets.add(new GreekAlphabet("Η", "η", "eta"));
greekAlphabets.add(new GreekAlphabet("Θ", "θ", "theta"));
greekAlphabets.add(new GreekAlphabet("Ι", "ι", "iota"));
greekAlphabets.add(new GreekAlphabet("Κ", "κ", "kappa"));
greekAlphabets.add(new GreekAlphabet("Λ", "λ", "lambda"));
greekAlphabets.add(new GreekAlphabet("Μ", "μ", "mu"));
greekAlphabets.add(new GreekAlphabet("Ν", "ν", "nu"));
greekAlphabets.add(new GreekAlphabet("Ξ", "ξ", "xi"));
greekAlphabets.add(new GreekAlphabet("Ο", "ο", "omicron"));
greekAlphabets.add(new GreekAlphabet("Π", "π", "pi"));
greekAlphabets.add(new GreekAlphabet("Ρ", "ρ", "rho"));
greekAlphabets.add(new GreekAlphabet("Σ", "σ (ς)", "sigma"));
greekAlphabets.add(new GreekAlphabet("Τ", "τ", "tau"));
greekAlphabets.add(new GreekAlphabet("Υ", "υ", "upsilon"));
greekAlphabets.add(new GreekAlphabet("Φ", "φ", "phi"));
greekAlphabets.add(new GreekAlphabet("Χ", "χ", "chi"));
greekAlphabets.add(new GreekAlphabet("Ψ", "ψ", "psi"));
greekAlphabets.add(new GreekAlphabet("Ω", "ω", "omega"));
}

/**
Expand Down Expand Up @@ -249,4 +280,14 @@ public String randomEnglishText(int words) {
Preconditions.checkArgument(words > 1, "词语数量必须大于1");
return StringUtils.capitalize(Joiner.on(" ").join(ResourceUtils.getRandomElement(englishWordsList, words)));
}

/**
* 随机希腊字母
*
* @return 随机希腊字母
* @since 1.0.20
*/
public GreekAlphabet randomGreekAlphabet() {
return ResourceUtils.getRandomElement(greekAlphabets);
}
}
Loading

0 comments on commit 34f0c6d

Please sign in to comment.