src/jdk.management.jfr/share/classes/jdk/management/jfr/ConfigurationInfo.java
author jjg
Fri, 11 Jan 2019 11:32:00 -0800
changeset 53286 5fa71cce89eb
parent 50113 caf115bb98ad
permissions -rw-r--r--
8210561: Command-line help wrong for javac --module Reviewed-by: darcy
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.Collection;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    29
import java.util.Collections;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    30
import java.util.HashMap;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    31
import java.util.Map;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    32
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    33
import javax.management.openmbean.CompositeData;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    34
import javax.management.openmbean.TabularData;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    35
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    36
import jdk.jfr.Configuration;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    37
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    38
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    39
/**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    40
 * Management representation of a {@code Configuration}.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    41
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    42
 * @see Configuration
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    43
 *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    44
 * @since 9
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    45
 */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    46
public final class ConfigurationInfo {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    47
    private final Map<String, String> settings;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    48
    private final String name;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    49
    private final String label;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    50
    private final String description;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    51
    private final String provider;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    52
    private final String contents;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    53
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    54
    ConfigurationInfo(Configuration config) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    55
        this.settings = config.getSettings();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    56
        this.name = config.getName();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    57
        this.label = config.getLabel();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    58
        this.description = config.getDescription();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    59
        this.provider = config.getProvider();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    60
        this.contents = config.getContents();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    61
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    62
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    63
    private ConfigurationInfo(CompositeData cd) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    64
        this.settings = createMap(cd.get("settings"));
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    65
        this.name = (String) cd.get("name");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    66
        this.label = (String) cd.get("label");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    67
        this.description = (String) cd.get("description");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    68
        this.provider = (String) cd.get("provider");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    69
        this.contents = (String) cd.get("contents");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    70
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    71
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    72
    private static Map<String, String> createMap(Object o) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    73
        if (o instanceof TabularData) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    74
            TabularData td = (TabularData) o;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    75
            Collection<?> values = td.values();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    76
            Map<String, String> map = new HashMap<>(values.size());
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    77
            for (Object value : td.values()) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    78
                if (value instanceof CompositeData) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    79
                    CompositeData cdRow = (CompositeData) value;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    80
                    Object k = cdRow.get("key");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    81
                    Object v = cdRow.get("value");
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    82
                    if (k instanceof String && v instanceof String) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    83
                        map.put((String) k, (String) v);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    84
                    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    85
                }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    86
            }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    87
            return Collections.unmodifiableMap(map);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    88
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    89
        return Collections.emptyMap();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    90
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    91
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    92
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    93
     * Returns the provider of the configuration associated with this
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    94
     * {@code ConfigurationInfo} (for example, {@code "OpenJDK"}).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    95
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    96
     * @return the provider, or {@code null} if doesn't exist
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    97
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    98
     * @see Configuration#getProvider()
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
    99
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   100
    public String getProvider() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   101
        return provider;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   102
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   103
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   104
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   105
     * Returns the textual representation of the configuration associated with
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   106
     * this {@code ConfigurationInfo}, typically the contents of the
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   107
     * configuration file that was used to create the configuration.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   108
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   109
     * @return contents, or {@code null} if doesn't exist
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   110
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   111
     * @see Configuration#getContents()
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   112
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   113
    public String getContents() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   114
        return contents;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   115
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   116
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   117
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   118
     * Returns the settings for the configuration associated with this
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   119
     * {@code ConfigurationInfo}.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   120
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   121
     * @return a {@code Map} with settings, not {@code null}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   122
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   123
     * @see Configuration#getSettings()
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   124
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   125
    public Map<String, String> getSettings() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   126
        return settings;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   127
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   128
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   129
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   130
     * Returns the human-readable name (for example, {@code "Continuous"} or {@code "Profiling"}) for
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   131
     * the configuration associated with this {@code ConfigurationInfo}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   132
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   133
     * @return the label, or {@code null} if doesn't exist
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   134
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   135
     * @see Configuration#getLabel()
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   136
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   137
    public String getLabel() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   138
        return label;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   139
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   140
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   141
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   142
     * Returns the name of the configuration associated with this
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   143
     * {@code ConfigurationInfo} (for example, {@code "default"}).
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   144
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   145
     * @return the name, or {@code null} if doesn't exist
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   146
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   147
     * @see Configuration#getLabel()
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   148
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   149
    public String getName() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   150
        return name;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   151
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   152
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   153
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   154
     * Returns a short sentence that describes the configuration associated with
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   155
     * this {@code ConfigurationInfo} (for example, {@code "Low
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   156
     * overhead configuration safe for continuous use in production
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   157
     * environments"}.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   158
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   159
     * @return the description, or {@code null} if doesn't exist
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   160
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   161
    public String getDescription() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   162
        return description;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   163
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   164
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   165
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   166
     * Returns a {@code ConfigurationInfo} object represented by the specified
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   167
     * {@code CompositeData}.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   168
     * <p>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   169
     * The following table shows the required attributes that the specified {@code CompositeData} must contain.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   170
     * <blockquote>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   171
     * <table class="striped">
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   172
     * <caption>Required names and types for CompositeData</caption>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   173
     * <thead>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   174
     * <tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   175
     * <th scope="col" style="text-align:left">Name</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   176
     * <th scope="col" style="text-align:left">Type</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   177
     * </tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   178
     * </thead>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   179
     * <tbody>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   180
     * <tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   181
     * <th scope="row">name</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">label</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">description</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">provider</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
     * <tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   197
     * <th scope="row">contents</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   198
     * <td>{@code String}</td>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   199
     * </tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   200
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   201
     * <tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   202
     * <th scope="row">settings</th>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   203
     * <td>{@code javax.management.openmbean.TabularData} with a
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   204
     * {@code TabularType} with the keys {@code "key"} and {@code "value"}, both
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   205
     * of the {@code String} type</td>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   206
     * </tr>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   207
     * </tbody>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   208
     * </table>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   209
     * </blockquote>
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   210
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   211
     * @param cd {@code CompositeData} representing a {@code ConfigurationInfo}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   212
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   213
     * @throws IllegalArgumentException if {@code cd} does not represent a
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   214
     *         {@code ConfigurationInfo} with the required attributes
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   215
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   216
     * @return a {@code ConfigurationInfo} object represented by {@code cd} if
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   217
     *         {@code cd} is not {@code null}, {@code null} otherwise
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   218
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   219
    public static ConfigurationInfo from(CompositeData cd) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   220
        if (cd == null) {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   221
            return null;
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   222
        }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   223
        return new ConfigurationInfo(cd);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   224
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   225
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   226
    /**
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   227
     * Returns a description of the configuration that is associated with this
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   228
     * {@code ConfigurationInfo}.
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   229
     *
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   230
     * @return the description of the configuration, not {@code null}
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   231
     */
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   232
    @Override
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   233
    public String toString() {
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   234
        Stringifier s = new Stringifier();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   235
        s.add("name", name);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   236
        s.add("label", label);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   237
        s.add("description", description);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   238
        s.add("provider", provider);
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   239
        return s.toString();
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   240
    }
caf115bb98ad 8199712: Flight Recorder
egahlin
parents:
diff changeset
   241
}