Java Collection Create toCollection(Object o)

Here you can find the source of toCollection(Object o)

Description

to Collection

License

Open Source License

Declaration

public static Collection toCollection(Object o) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Collection;
import java.util.Collections;

public class Main {
    public static Collection toCollection(Object o) {
        if (o == null) {
            return Collections.emptyList();
        } else {//from   w  w  w  .ja v a2  s  . c  o  m
            return Collections.singletonList(o);
        }
    }
}

Related

  1. toCollection(final char[] charArray)
  2. toCollection(final Iterable iterable)
  3. toCollection(final T[] elements)
  4. toCollection(Iterable iterable)
  5. toCollection(Iterable i)
  6. toCollection(String value)