blob: 196a7e346bf8010507a315a9c576b5b2693e4569 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/*****************************************************************************
* Copyright (c) 2012 CEA LIST.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.infra.tools.util;
import java.util.ArrayList;
import java.util.List;
public class ListHelper {
/**
* Converts an array to a List
*
* This method is similar to Arrays.asList, except that it returns
* a writeable list
*
* @param array
* The array to transform into a List
* @return
* A List containing the same elements as the array
*/
public static <T> List<T> asList(T[] array) {
if(array == null) {
return new ArrayList<T>();
}
List<T> result = new ArrayList<T>(array.length);
for(T t : array) {
result.add(t);
}
return result;
}
}
|