1/*
2 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package com.sun.management.internal;
27
28import java.util.List;
29
30/**
31 * Diagnostic command information. It contains the description of a
32 * diagnostic command.
33 *
34 * @since 1.8
35 */
36
37class DiagnosticCommandInfo {
38    private final String name;
39    private final String description;
40    private final String impact;
41    private final String permissionClass;
42    private final String permissionName;
43    private final String permissionAction;
44    private final boolean enabled;
45    private final List<DiagnosticCommandArgumentInfo> arguments;
46
47    /**
48     * Returns the diagnostic command name.
49     *
50     * @return the diagnostic command name
51     */
52    String getName() {
53        return name;
54    }
55
56   /**
57     * Returns the diagnostic command description.
58     *
59     * @return the diagnostic command description
60     */
61    String getDescription() {
62        return description;
63    }
64
65    /**
66     * Returns the potential impact of the diagnostic command execution
67     *         on the Java virtual machine behavior.
68     *
69     * @return the potential impact of the diagnostic command execution
70     *         on the Java virtual machine behavior
71     */
72    String getImpact() {
73        return impact;
74    }
75
76    /**
77     * Returns the name of the permission class required to be allowed
78     *         to invoke the diagnostic command, or null if no permission
79     *         is required.
80     *
81     * @return the name of the permission class name required to be allowed
82     *         to invoke the diagnostic command, or null if no permission
83     *         is required
84     */
85    String getPermissionClass() {
86        return permissionClass;
87    }
88
89    /**
90     * Returns the permission name required to be allowed to invoke the
91     *         diagnostic command, or null if no permission is required.
92     *
93     * @return the permission name required to be allowed to invoke the
94     *         diagnostic command, or null if no permission is required
95     */
96    String getPermissionName() {
97        return permissionName;
98    }
99
100    /**
101     * Returns the permission action required to be allowed to invoke the
102     *         diagnostic command, or null if no permission is required or
103     *         if the permission has no action specified.
104     *
105     * @return the permission action required to be allowed to invoke the
106     *         diagnostic command, or null if no permission is required or
107     *         if the permission has no action specified
108     */
109    String getPermissionAction() {
110        return permissionAction;
111    }
112
113    /**
114     * Returns {@code true} if the diagnostic command is enabled,
115     *         {@code false} otherwise. The enabled/disabled
116     *         status of a diagnostic command can evolve during
117     *         the lifetime of the Java virtual machine.
118     *
119     * @return {@code true} if the diagnostic command is enabled,
120     *         {@code false} otherwise
121     */
122    boolean isEnabled() {
123        return enabled;
124    }
125
126    /**
127     * Returns the list of the diagnostic command arguments description.
128     * If the diagnostic command has no arguments, it returns an empty list.
129     *
130     * @return a list of the diagnostic command arguments description
131     */
132    List<DiagnosticCommandArgumentInfo> getArgumentsInfo() {
133        return arguments;
134    }
135
136    DiagnosticCommandInfo(String name, String description,
137                                    String impact, String permissionClass,
138                                    String permissionName, String permissionAction,
139                                    boolean enabled,
140                                    List<DiagnosticCommandArgumentInfo> arguments)
141    {
142        this.name = name;
143        this.description = description;
144        this.impact = impact;
145        this.permissionClass = permissionClass;
146        this.permissionName = permissionName;
147        this.permissionAction = permissionAction;
148        this.enabled = enabled;
149        this.arguments = arguments;
150    }
151}
152