当前位置: 首页>>代码示例>>Java>>正文


Java ImmutableDescriptor.getFieldValues方法代码示例

本文整理汇总了Java中javax.management.ImmutableDescriptor.getFieldValues方法的典型用法代码示例。如果您正苦于以下问题:Java ImmutableDescriptor.getFieldValues方法的具体用法?Java ImmutableDescriptor.getFieldValues怎么用?Java ImmutableDescriptor.getFieldValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.management.ImmutableDescriptor的用法示例。


在下文中一共展示了ImmutableDescriptor.getFieldValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import javax.management.ImmutableDescriptor; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    ImmutableDescriptor immutableEmpty = new ImmutableDescriptor();
    DescriptorSupport mutableEmpty = new DescriptorSupport();

    checkEmpty(union());
    checkEmpty(union(immutableEmpty));
    checkEmpty(union(mutableEmpty));
    checkEmpty(union(EMPTY_DESCRIPTOR, immutableEmpty, mutableEmpty));
    checkEmpty(union(null, immutableEmpty, null));

    ImmutableDescriptor immutableNumbers =
        new ImmutableDescriptor(new String[] {"one", "two", "three"},
                                new Object[] {1, 2, 3});
    final String[] noNames = null;
    DescriptorSupport mutableNumbers =
        new DescriptorSupport(immutableNumbers.getFieldNames(),
                              immutableNumbers.getFieldValues(noNames));
    ImmutableDescriptor immutableOne =
        new ImmutableDescriptor(Collections.singletonMap("one", 1));
    DescriptorSupport mutableOne =
        new DescriptorSupport(new String[] {"one"}, new Object[] {1});
    ImmutableDescriptor immutableTwo =
        new ImmutableDescriptor(Collections.singletonMap("two", 2));
    DescriptorSupport mutableTwo =
        new DescriptorSupport(new String[] {"two"}, new Object[] {2});
    ImmutableDescriptor immutableOneTwo =
        new ImmutableDescriptor(new String[] {"one", "two"},
                                new Object[] {1, 2});


    checkEqual(union(immutableNumbers), immutableNumbers);
    checkEqual(union(immutableNumbers, mutableNumbers), immutableNumbers);
    checkEqual(union(mutableNumbers, immutableNumbers), immutableNumbers);
    checkEqual(union(mutableEmpty, immutableEmpty, immutableNumbers,
                     mutableNumbers, immutableOne), immutableNumbers);
    checkEqual(union(immutableOne, immutableTwo, immutableNumbers),
               immutableNumbers);
    checkEquivalent(union(immutableOne, mutableNumbers), immutableNumbers);
    checkEquivalent(union(immutableOne, immutableTwo), immutableOneTwo);
    checkEquivalent(union(mutableOne, mutableTwo), immutableOneTwo);

    if (failure != null)
        throw new Exception("TEST FAILED: " + failure);
    System.out.println("TEST PASSED");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:46,代码来源:UnionTest.java

示例2: main

import javax.management.ImmutableDescriptor; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    boolean ok = true;
    ImmutableDescriptor d = new ImmutableDescriptor(
            new String[] {
                "strings", "ints", "booleans",
            },
            new Object[] {
                new String[] {"foo"},
                new int[] {5},
                new boolean[] {false},
            });

    String[] strings = (String[]) d.getFieldValue("strings");
    strings[0] = "bar";
    strings = (String[]) d.getFieldValue("strings");
    if (!strings[0].equals("foo")) {
        System.out.println("FAILED: modified string array field");
        ok = false;
    }

    int[] ints = (int[]) d.getFieldValue("ints");
    ints[0] = 0;
    ints = (int[]) d.getFieldValue("ints");
    if (ints[0] != 5) {
        System.out.println("FAILED: modified int array field");
        ok = false;
    }

    boolean[] bools = (boolean[]) d.getFieldValue("booleans");
    bools[0] = true;
    bools = (boolean[]) d.getFieldValue("booleans");
    if (bools[0]) {
        System.out.println("FAILED: modified boolean array field");
        ok = false;
    }

    Object[] values = d.getFieldValues("strings", "ints", "booleans");
    ((String[]) values[0])[0] = "bar";
    ((int[]) values[1])[0] = 0;
    ((boolean[]) values[2])[0] = true;
    values = d.getFieldValues("strings", "ints", "booleans");
    if (!((String[]) values[0])[0].equals("foo") ||
            ((int[]) values[1])[0] != 5 ||
            ((boolean[]) values[2])[0]) {
        System.out.println("FAILED: getFieldValues modifiable: " +
                Arrays.deepToString(values));
    }

    if (ok)
        System.out.println("TEST PASSED");
    else
        throw new Exception("Array field values were modifiable");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:54,代码来源:ImmutableArrayFieldTest.java


注:本文中的javax.management.ImmutableDescriptor.getFieldValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。