Git Product home page Git Product logo

collection-chain's Introduction

collection-chain

Java List链式操作,Map链式操作,Set链式操作

说明

Java中的集合是没有链式操作的,有时候在项目在写大量的add、put,而调用对象都是同一个,大量的add、put看起来会觉得很别扭,如果能做到链式操作,看起来应该会更优雅~   上面提供了List、Set、Map的链式操作源码,使用也很简单,大家有兴趣的可以copy下来试试。

使用

  • List
List<String> strList = ListBuilder.build(String.class)
				.add("str1").add("str2")
				.get();
 
或者:
List<String> strList = new ListBuilder<String>()
			.add("str1").add("str2")
			.get();
  • map
Map<String,Object> map = new MapBuilder<String,Object>()
					.put("key", "value")
					.get();
          
或者:
Map<String,Object> map = MapBuilder.buildHashMap(String.class, Object.class)
				.put("key", "value")
				.get();
  • set
Set<Person> personSet = SetBuilder.build(Person.class)
				.add(new Person("zs", 23)).add(new Person("ls", 25)).get();
        
或者:
Set<Person> personSet = new SetBuilder<Person>()
				.add(new Person("zs", 23)).add(new Person("ls", 25)).get();
        

collection-chain's People

Contributors

mockcm avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.