forked from BeyondDimension/SteamTools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaGenericHelper.cs
More file actions
30 lines (28 loc) · 975 Bytes
/
JavaGenericHelper.cs
File metadata and controls
30 lines (28 loc) · 975 Bytes
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
using System;
using System.Collections.Generic;
using Object = Java.Lang.Object;
// ReSharper disable once CheckNamespace
namespace Android.Runtime
{
/// <summary>
/// Java 泛型 助手类
/// </summary>
public static class JavaGenericHelper
{
/// <summary>
/// <see cref="Java.Util.Arrays.AsList(Object[])"/> 代替方法
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="a"></param>
/// <returns></returns>
public static IList<T> AsList<T>(params T[] a) => new JavaList<T>(a);
/// <summary>
/// 适用于实现接口 <see cref="IParcelableCreator.NewArray(int)"/>
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="ts"></param>
/// <returns></returns>
public static Object[] NewArray<T>(T[] ts) where T : IJavaObject
=> Array.ConvertAll(ts, x => Extensions.JavaCast<Object>(x));
}
}