-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐳 [动态属性] 增加 ifNull 方法,如果动态属性值为 null,则执行给定的操作,否则不执行任何操作。执行给定操作后将得到一个返回…
…值,该返回值会设置到动态属性中。 Runner 机制相关 javadoc 补充 整理示例文档相关内容
- Loading branch information
Showing
9 changed files
with
180 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...on/common-core/src/main/java/com/iohao/game/action/skeleton/core/runner/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* ioGame | ||
* Copyright (C) 2021 - present 渔民小镇 ([email protected]、[email protected]) . All Rights Reserved. | ||
* # iohao.com . 渔民小镇 | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
/** | ||
* {@link com.iohao.game.action.skeleton.core.runner.Runner} 机制类似于 Spring CommandLineRunner 的启动项,它能够在逻辑服务器启动之后调用一次 Runner 接口实现类,让开发者能够通过实现 Runner 接口来扩展自身的系统。 | ||
* <p> | ||
* Runner 机制,会在逻辑服与 Broker(游戏网关)建立连接之前、之后分别触发一次对应的方法。<a href="https://www.yuque.com/iohao/game/dpwe6r6sqwwtrh1q">相关文档</a> | ||
* | ||
* @author 渔民小镇 | ||
* @date 2024-06-05 | ||
*/ | ||
package com.iohao.game.action.skeleton.core.runner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
.../common-micro-kit/src/test/java/com/iohao/game/common/kit/attr/AttrOptionDynamicTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.iohao.game.common.kit.attr; | ||
|
||
import lombok.Getter; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author 渔民小镇 | ||
* @date 2024-06-05 | ||
*/ | ||
public class AttrOptionDynamicTest { | ||
|
||
final MyAttrOptions myAttrOptions = new MyAttrOptions(); | ||
|
||
AttrOption<AttrCat> catAttrOption = AttrOption.valueOf("AttrCat"); | ||
|
||
@Test | ||
public void ifNull() { | ||
Assert.assertNull(myAttrOptions.option(catAttrOption)); | ||
|
||
myAttrOptions.ifNull(catAttrOption, AttrCat::new); | ||
Assert.assertNotNull(myAttrOptions.option(catAttrOption)); | ||
|
||
myAttrOptions.option(catAttrOption, null); | ||
Assert.assertNull(myAttrOptions.option(catAttrOption)); | ||
|
||
AttrCat attrCat = new AttrCat(); | ||
attrCat.name = "a"; | ||
myAttrOptions.option(catAttrOption, attrCat); | ||
myAttrOptions.ifNull(catAttrOption, AttrCat::new); | ||
Assert.assertEquals(myAttrOptions.option(catAttrOption).name, attrCat.name); | ||
} | ||
|
||
private static class AttrCat { | ||
String name; | ||
} | ||
|
||
@Getter | ||
private static class MyAttrOptions implements AttrOptionDynamic { | ||
final AttrOptions options = new AttrOptions(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters