Google Guava Supplier Example

前端 未结 6 1133
感情败类
感情败类 2021-02-02 07:23

Please explain the use of the interface Supplier(in Guava) with a suitable example .

6条回答
  •  -上瘾入骨i
    2021-02-02 08:19

    The main reason we included Supplier in Guava was to support the Multimaps methods that generate arbitrary Multimaps, such as

    public static  Multimap newMultimap(Map> map,
        Supplier> factory)
    

    The Supplier creates a Collection that holds all of the values for a given key. The Multimap uses the Supplier whenever you store a key-value pair with a key that's not already in the Multimap.

提交回复
热议问题