本文整理汇总了Java中org.apache.ignite.internal.util.typedef.internal.U.compact方法的典型用法代码示例。如果您正苦于以下问题:Java U.compact方法的具体用法?Java U.compact怎么用?Java U.compact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.ignite.internal.util.typedef.internal.U
的用法示例。
在下文中一共展示了U.compact方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compactArray
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Joins array elements to string.
*
* @param arr Array.
* @return String.
*/
@Nullable public static String compactArray(Object[] arr) {
if (arr == null || arr.length == 0)
return null;
String sep = ", ";
StringBuilder sb = new StringBuilder();
for (Object s : arr)
sb.append(s).append(sep);
if (sb.length() > 0)
sb.setLength(sb.length() - sep.length());
return U.compact(sb.toString());
}
示例2: compactIterable
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Joins iterable collection elements to string.
*
* @param col Iterable collection.
* @return String.
*/
@Nullable public static String compactIterable(Iterable col) {
if (col == null || !col.iterator().hasNext())
return null;
String sep = ", ";
StringBuilder sb = new StringBuilder();
for (Object s : col)
sb.append(s).append(sep);
if (sb.length() > 0)
sb.setLength(sb.length() - sep.length());
return U.compact(sb.toString());
}
示例3: compactClass
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Compact class names.
*
* @param cls Class object for compact.
* @return Compacted string.
*/
@Nullable public static String compactClass(Class cls) {
if (cls == null)
return null;
return U.compact(cls.getName());
}
示例4: compactObject
import org.apache.ignite.internal.util.typedef.internal.U; //导入方法依赖的package包/类
/**
* Returns compact class host.
*
* @param obj Object to compact.
* @return String.
*/
@Nullable public static Object compactObject(Object obj) {
if (obj == null)
return null;
if (obj instanceof Enum)
return obj.toString();
if (obj instanceof String || obj instanceof Boolean || obj instanceof Number)
return obj;
if (obj instanceof Collection) {
Collection col = (Collection)obj;
Object[] res = new Object[col.size()];
int i = 0;
for (Object elm : col)
res[i++] = compactObject(elm);
return res;
}
if (obj.getClass().isArray()) {
Class<?> arrType = obj.getClass().getComponentType();
if (arrType.isPrimitive()) {
if (obj instanceof boolean[])
return Arrays.toString((boolean[])obj);
if (obj instanceof byte[])
return Arrays.toString((byte[])obj);
if (obj instanceof short[])
return Arrays.toString((short[])obj);
if (obj instanceof int[])
return Arrays.toString((int[])obj);
if (obj instanceof long[])
return Arrays.toString((long[])obj);
if (obj instanceof float[])
return Arrays.toString((float[])obj);
if (obj instanceof double[])
return Arrays.toString((double[])obj);
}
Object[] arr = (Object[])obj;
int iMax = arr.length - 1;
StringBuilder sb = new StringBuilder("[");
for (int i = 0; i <= iMax; i++) {
sb.append(compactObject(arr[i]));
if (i != iMax)
sb.append(", ");
}
sb.append(']');
return sb.toString();
}
return U.compact(obj.getClass().getName());
}