Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

业务参数自动装箱、拆箱基础类型-int #42

Closed
iohao opened this issue Feb 11, 2023 · 1 comment
Closed

业务参数自动装箱、拆箱基础类型-int #42

iohao opened this issue Feb 11, 2023 · 1 comment
Labels
功能增强 功能增强

Comments

@iohao
Copy link
Owner

iohao commented Feb 11, 2023

主要解决两个问题

  • 碎片协议
  • 使用时可自动装箱和拆箱

类似的 https://www.yuque.com/iohao/game/ieimzn

@iohao
Copy link
Owner Author

iohao commented Feb 11, 2023

业务参数自动装箱、拆箱基础类型-int

使用示例,下面两个方法是等价的。

@ActionController(6)
public class IntAction {
    @ActionMethod(10)
    public int int2int(int value) {
        return value + 1;
    }

    @ActionMethod(11)
    public IntValue intValue2intValue(IntValue intValue) {
        IntValue newIntValue = new IntValue();
        newIntValue.value = intValue.value + 1;
        return newIntValue;
    }
}

int 类型在 action 方法中的参数与返回值还可以使用 List 类型,下面两个方法也是等价的。

@ActionController(6)
public class IntAction {
    @ActionMethod(12)
    public List<Integer> intList2intList(List<Integer> intList) {
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);
        return list;
    }

    @ActionMethod(13)
    public IntValueList intValueList2intValueList(IntValueList intValueList) {
        List<Integer> list = new ArrayList<>();
        list.add(1);
        list.add(2);

        IntValueList newIntValueList = new IntValueList();
        newIntValueList.values = list;

        return newIntValueList;
    }
}

@iohao iohao added the 功能增强 功能增强 label Feb 11, 2023
@iohao iohao closed this as completed Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
功能增强 功能增强
Projects
None yet
Development

No branches or pull requests

1 participant