Skip to content

Commit

Permalink
翻译基因内容
Browse files Browse the repository at this point in the history
  • Loading branch information
ZherKing committed Sep 2, 2023
1 parent b225508 commit 116dc7a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public class Allele implements Comparable<Allele> {
private final boolean dominant;

public Allele(String uid, String name, boolean dominant) {
Validate.notEmpty(uid, "The allele uid must not be null or empty!");
Validate.isTrue(PatternUtil.UID_PATTERN.matcher(uid).matches(), "The allele uid must start with a prefix " +
Validate.notEmpty(uid, "等位基因 uid 不得为空或为空!");
Validate.isTrue(PatternUtil.UID_PATTERN.matcher(uid).matches(), "等位基因 uid 必须以前缀开头 " +
"and be in the lower snake case format, got " + uid + "!");
Validate.notEmpty(name, "The allele name must not be null or empty!");
Validate.isTrue(PatternUtil.UPPER_SNAKE.matcher(name).matches(), "The allele name must be " +
Validate.notEmpty(name, "等位基因名称不得为无或空!");
Validate.isTrue(PatternUtil.UPPER_SNAKE.matcher(name).matches(), "等位基因名称必须为 " +
"in the upper snake case format, got " + name + "!");

this.uid = uid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class AlleleEffect extends Allele {
public AlleleEffect(String uid, String name, EffectFunction effectFunction, boolean dominant) {
super(uid, name, dominant);

Validate.notNull(effectFunction, "The effect function cannot be null!");
Validate.notNull(effectFunction, "效果函数不能为空!");

this.effectFunction = effectFunction;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class AllelePlant extends Allele {
public AllelePlant(String uid, String name, Material value, boolean dominant) {
super(uid, name, dominant);

Validate.isTrue(value.isBlock(), "The material of AllelePlant has to be a block, got " + value + "!");
Validate.isTrue(value.isBlock(), "等位基因植物的材料必须是块状的,得到 " + value + "!");
this.value = value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public Allele get(ChromosomeType type, String uid) {
*/
@SuppressWarnings("unchecked")
public <T extends Allele> void register(ChromosomeType type, T allele) {
Validate.notNull(type, "Cannot register an Allele for null ChromosomeType!");
Validate.notNull(allele, "Cannot register a null Allele!");
Validate.notNull(type, "无法为零染色体类型注册等位基因!");
Validate.notNull(allele, "无法注册空等位基因!");

if (!type.getAlleleClass().isAssignableFrom(allele.getClass())) {
throw new IllegalArgumentException("Allele class (" + allele.getClass()
+ ") does not match required ChromosomeType class (" + type.getAlleleClass() + ")!");
throw new IllegalArgumentException("等位基因类 (" + allele.getClass()
+ ") 与所需的染色体类型类不匹配 (" + type.getAlleleClass() + ")!");
}

Map<String, T> alleleMap = (Map<String, T>) allelesByChromosomeType.computeIfAbsent(type, k -> new LinkedHashMap<>());
Expand All @@ -72,9 +72,9 @@ public <T extends Allele> void register(ChromosomeType type, T allele) {
* @param <V> The type of the {@link AlleleValue} that is used to create the {@link Allele} instance
*/
public <T, V extends AlleleValue<T>> void register(ChromosomeType type, V alleleValue, String uid) {
Validate.notNull(type, "The chromosome type cannot be null!");
Validate.notEmpty(uid, "The allele uid cannot be null or empty!");
Validate.notNull(alleleValue, "The allele value cannot be null!");
Validate.notNull(type, "染色体类型不能为空!");
Validate.notEmpty(uid, "等位基因 uid 不能为无或空!");
Validate.notNull(alleleValue, "等位基因值不能为空!");

boolean dominant = alleleValue.isDominant();
T value = alleleValue.getValue();
Expand All @@ -94,7 +94,7 @@ public <T, V extends AlleleValue<T>> void register(ChromosomeType type, V allele
AlleleEffect allele = new AlleleEffect(uid, name, (AlleleEffect.EffectFunction) value, dominant);
register(type, allele);
} else {
throw new IllegalArgumentException("Could not create allele for uid: " + uid + " and value " + valueClass);
throw new IllegalArgumentException("无法为 uid 创建等位基因: " + uid + " 和变量 " + valueClass);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public AlleleService(AlleleRegistry alleleRegistry) {
}

public void set(Allele[] template, ChromosomeType type, String uid) {
Validate.notNull(template, "Cannot update null allele template!");
Validate.notNull(type, "Cannot update alleles belonging to null ChromosomeType!");
Validate.notNull(uid, "Cannot update alleles by allele with null uid!");
Validate.notNull(template, "无法更新空等位基因模板!");
Validate.notNull(type, "无法更新属于空染色体类型的等位基因!");
Validate.notNull(uid, "无法通过等位基因更新具有空 uid 的等位基因!");

Allele allele = alleleRegistry.get(type, uid);
if (allele == null) {
throw new IllegalArgumentException("There is no Allele for type: " + type + " and uid: " + uid);
throw new IllegalArgumentException("这里没有该类型的等位基因: " + type + " uid: " + uid);
}

template[type.ordinal()] = allele;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public AlleleValue(T value) {
}

public AlleleValue(T value, boolean dominant) {
Validate.notNull(value, "Cannot create AlleleValue from null value!");
Validate.notNull(value, "无法从空值创建等位基因值!");

this.value = value;
this.dominant = dominant;
Expand Down

0 comments on commit 116dc7a

Please sign in to comment.