src/jdk.management.jfr/share/classes/jdk/management/jfr/SettingDescriptorInfo.java
author michaelm
Thu, 14 Nov 2019 08:27:28 +0000
branchunixdomainchannels
changeset 59073 832b8a28e17f
parent 50113 caf115bb98ad
permissions -rw-r--r--
unixdomainchannels: test updates
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     1
/*
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     2
 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     4
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    10
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    15
 * accompanied this code).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    16
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    20
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    23
 * questions.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    24
 */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    25
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    26
package jdk.management.jfr;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    27
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    28
import java.util.concurrent.Callable;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    29
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    30
import javax.management.openmbean.CompositeData;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    31
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    32
import jdk.jfr.EventType;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    33
import jdk.jfr.SettingDescriptor;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    34
import jdk.management.jfr.internal.FlightRecorderMXBeanProvider;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    35
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    36
/**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    37
 * Management class that describes a setting, for example name, description and
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    38
 * default value.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    39
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    40
 * @see EventType#getSettingDescriptors()
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    41
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    42
 * @since 9
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    43
 */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    44
public final class SettingDescriptorInfo {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    45
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    46
    // Purpose of this static initializer is to allow
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    47
    // FlightRecorderMXBeanProvider
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    48
    // to be in an internal package and not visible, but at the same time allow
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    49
    // it to instantiate FlightRecorderMXBeanImpl.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    50
    //
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    51
    // The reason the mechanism is in this class is because it is light weight
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    52
    // and can easily be triggered from FlightRecorderMXBeanProvider.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    53
    static {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    54
        FlightRecorderMXBeanProvider.setFlightRecorderMXBeanFactory(new Callable<FlightRecorderMXBean>() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    55
            @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    56
            public FlightRecorderMXBean call() throws Exception {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    57
                return new FlightRecorderMXBeanImpl();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    58
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    59
        });
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    60
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    61
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    62
    private final String name;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    63
    private final String label;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    64
    private final String description;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    65
    private final String typeName;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    66
    private final String contentType;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    67
    private final String defaultValue;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    68
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    69
    // package private
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    70
    SettingDescriptorInfo(SettingDescriptor settingDescriptor) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    71
        this.name = settingDescriptor.getName();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    72
        this.label = settingDescriptor.getLabel();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    73
        this.description = settingDescriptor.getDescription();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    74
        this.typeName = settingDescriptor.getTypeName();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    75
        this.contentType = settingDescriptor.getContentType();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    76
        this.defaultValue = settingDescriptor.getDefaultValue();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    77
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    78
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    79
    private SettingDescriptorInfo(CompositeData cd) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    80
        this.name = (String) cd.get("name");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    81
        this.label = (String) cd.get("label");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    82
        this.description = (String) cd.get("description");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    83
        this.typeName = (String) cd.get("typeName");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    84
        this.defaultValue = (String) cd.get("defaultValue");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    85
        this.contentType = (String) cd.get("contentType");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    86
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    87
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    88
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    89
    * Returns the human-readable name of the setting associated with this
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    90
     * {@code SettingDescriptorInfo} (for example, {@code "Threshold"}).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    91
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    92
     * @return the label for this setting, not {@code null}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    93
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    94
    public String getLabel() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    95
        return label;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    96
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    97
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    98
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    99
     * Returns the name of the setting associated with this
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   100
     * {@code SettingDescriptorInfo} (for example, {@code "threshold"}).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   101
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   102
     * @return the name of this setting, not {@code null}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   103
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   104
    public String getName() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   105
        return name;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   106
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   107
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   108
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   109
     * Returns the description of the setting associated this
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   110
     * {@code SettingDescriptorInfo} (for example,
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   111
     * {@code "The duration an event must exceed to be be recorded"}).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   112
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   113
     * @return the description of this setting, not null
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   114
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   115
    public String getDescription() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   116
        return description;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   117
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   118
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   119
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   120
     * Returns the type name of the setting associated this
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   121
     * {@code SettingDescriptorInfo} (for example,
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   122
     * {@code "jdk.settings.Threshold"}).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   123
     * <p>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   124
     * The type can be used to identify what type of setting this is.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   125
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   126
     * @return the name of this settings type, not {@code null}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   127
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   128
    public String getTypeName() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   129
        return typeName;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   130
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   131
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   132
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   133
     * Returns the content type of the setting associated this
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   134
     * {@code SettingDescriptorInfo} (for example, {@code "jdk.jfr.Timespan"}).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   135
     * <p>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   136
     * The content type can be used to determine how the setting should be
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   137
     * rendered in a graphical user interface.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   138
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   139
     * @return the name of this settings type, not {@code null}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   140
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   141
    public String getContentType() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   142
        return contentType;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   143
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   144
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   145
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   146
     * Returns the default value of the setting associated this
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   147
     * {@code SettingDescriptorInfo} (for example, {@code "20 ms"}).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   148
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   149
     * @return default value for this setting, not {@code null}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   150
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   151
     * @see SettingDescriptor#getDefaultValue()
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   152
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   153
    public String getDefaultValue() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   154
        return defaultValue;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   155
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   156
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   157
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   158
     * Returns an {@code SettingDescriptorInfo} represented by the specified
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   159
     * {@code CompositeData}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   160
     * <p>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   161
     * The supplied {@code CompositeData} must have the following item names and
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   162
     * item types to be valid. <blockquote>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   163
     * <table class="striped">
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   164
     * <caption>The name and type the specified CompositeData must contain</caption>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   165
     * <thead>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   166
     * <tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   167
     * <th scope="col" style="text-align:left">Name</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   168
     * <th scope="col" style="text-align:left">Type</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   169
     * </tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   170
     * </thead>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   171
     * <tbody>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   172
     * <tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   173
     * <th scope="row">name</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   174
     * <td>{@code String}</td>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   175
     * </tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   176
     * <tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   177
     * <th scope="row">label</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   178
     * <td>{@code String}</td>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   179
     * </tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   180
     * <tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   181
     * <th scope="row">description</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   182
     * <td>{@code String}</td>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   183
     * </tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   184
     * <tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   185
     * <th scope="row">typeName</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   186
     * <td>{@code String}</td>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   187
     * </tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   188
     * <tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   189
     * <th scope="row">contentType</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   190
     * <td>{@code String}</td>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   191
     * </tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   192
     * <tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   193
     * <th scope="row">defaultValue</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   194
     * <td>{@code String}</td>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   195
     * </tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   196
     * </tbody>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   197
     * </table>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   198
     * </blockquote>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   199
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   200
     * @param cd {@code CompositeData} representing the {@code SettingDescriptorInfo} to
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   201
     *        return
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   202
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   203
     * @throws IllegalArgumentException if {@code cd} does not represent a valid
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   204
     *         {@code EventTypeInfo}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   205
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   206
     * @return a {@code SettingDescriptorInfo}, or {@code null} if {@code cd} is
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   207
     *         {@code null}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   208
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   209
    public static SettingDescriptorInfo from(CompositeData cd) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   210
        if (cd == null) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   211
            return null;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   212
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   213
        return new SettingDescriptorInfo(cd);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   214
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   215
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   216
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   217
     * Returns a {@code String} description of this {@code SettingDescriptorInfo}.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   218
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   219
     * @return a string describing this setting, not {@code null}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   220
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   221
    @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   222
    public String toString() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   223
        Stringifier s = new Stringifier();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   224
        s.add("name", name);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   225
        s.add("label", label);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   226
        s.add("description", description);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   227
        s.add("typeName", typeName);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   228
        s.add("contentType", contentType);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   229
        s.add("defaultValue", defaultValue);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   230
        return s.toString();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   231
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   232
}