Path: blob/master/src/java.desktop/share/classes/javax/sound/sampled/CompoundControl.java
41159 views
/*1* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.sound.sampled;2627import java.util.StringJoiner;2829/**30* A {@code CompoundControl}, such as a graphic equalizer, provides control over31* two or more related properties, each of which is itself represented as a32* {@code Control}.33*34* @author Kara Kytle35* @since 1.336*/37public abstract class CompoundControl extends Control {3839/**40* The set of member controls.41*/42private final Control[] controls;4344/**45* Constructs a new compound control object with the given parameters.46*47* @param type the type of control represented this compound control object48* @param memberControls the set of member controls49*/50protected CompoundControl(Type type, Control[] memberControls) {51super(type);52this.controls = memberControls;53}5455/**56* Returns the set of member controls that comprise the compound control.57*58* @return the set of member controls59*/60public Control[] getMemberControls() {61return controls.clone();62}6364/**65* Returns a string representation of the compound control.66*67* @return a string representation of the compound control68*/69@Override70public String toString() {71StringJoiner controls = new StringJoiner(", ", "[", "]");72for (Control control : getMemberControls()) {73controls.add(control.getType().toString());74}75return String.format("%s containing %s controls", super.toString(),76controls);77}7879/**80* An instance of the {@code CompoundControl.Type} inner class identifies81* one kind of compound control.82*83* @author Kara Kytle84* @since 1.385*/86public static class Type extends Control.Type {8788/**89* Constructs a new compound control type.90*91* @param name the name of the new compound control type92*/93protected Type(final String name) {94super(name);95}96}97}9899100