帮酷LOGO
  • 显示原文与译文双语对照的内容
用Builder生成泛型,generics type builder

  • 源代码名称:TypeBuilder
  • 源代码网址:http://www.github.com/ikidou/TypeBuilder
  • TypeBuilder源代码文档
  • TypeBuilder源代码下载
  • Git URL:
    git://www.github.com/ikidou/TypeBuilder.git
  • Git Clone代码到本地:
    git clone http://www.github.com/ikidou/TypeBuilder
  • Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/ikidou/TypeBuilder
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
  • TypeBuilder

    一个用于生成泛型的简易Builder

    Example for List<String>
    Type type =TypeBuilder        .newInstance(List.class)
            .addTypeParam(String.class)
            .build();
    Example for List<? super String>
    Type type =TypeBuilder        .newInstance(List.class)
            .addTypeParamSuper(String.class)
            .build();
    Example for List<? extends CharSequence>
    Type type =TypeBuilder        .newInstance(List.class)
            .addTypeParamExtends(CharSequence.class)
            .build();
    Example for Map<String, String[]>
    Type type =TypeBuilder        .newInstance(HashMap.class)
            .addTypeParam(String.class)
            .addTypeParam(String[].class)
            .build();
    Example for Map<String, List<String>>
    Type type =TypeBuilder        .newInstance(Map.class)
            .addTypeParam(String.class)
            .beginSubType(List.class) //开始 List<String> 部分        .addTypeParam(String.class) //设置List的泛型值        .endSubType() //结束 List<String> 部分        .build();
    Download

    Get it from JitPack repository use Gradle or Maven.
    Download JAR and Source

    有什么用

    当你无法通过子类去获取泛型时,不用写一长串的嵌套或去实现部分Type接口。

    License

    Copyright 2016 ikidou
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at
        http://www.apache.org/licenses/LICENSE-2.0
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.



    Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备05059198号-3  |  如果智培  |  酷兔英语