< prev index next >

src/java.desktop/share/classes/javax/sound/sampled/Control.java

Print this page
rev 57600 : 8236980: toString() cleanup in JavaSound
Reviewed-by: XXX
   1 /*
   2  * Copyright (c) 1999, 2017, 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


  49 
  50     /**
  51      * Constructs a control with the specified type.
  52      *
  53      * @param  type the kind of control desired
  54      */
  55     protected Control(Type type) {
  56         this.type = type;
  57     }
  58 
  59     /**
  60      * Obtains the control's type.
  61      *
  62      * @return the control's type
  63      */
  64     public Type getType() {
  65         return type;
  66     }
  67 
  68     /**
  69      * Obtains a string describing the control type and its current state.
  70      *
  71      * @return a string representation of the control
  72      */
  73     @Override
  74     public String toString() {
  75         return new String(getType() + " Control");
  76     }
  77 
  78     /**
  79      * An instance of the {@code Type} class represents the type of the control.
  80      */
  81     public static class Type {
  82 
  83         /**
  84          * Type name.
  85          */
  86         private final String name;
  87 
  88         /**
  89          * Constructs a new control type with the name specified. The name
  90          * should be a descriptive string appropriate for labelling the control
  91          * in an application, such as "Gain" or "Balance".
  92          *
  93          * @param  name the name of the new control type
  94          */
  95         protected Type(String name) {


 103          * @param  obj the reference object with which to compare
 104          * @return {@code true} if the specified object is equal to this control
 105          *         type; {@code false} otherwise
 106          */
 107         @Override
 108         public final boolean equals(Object obj) {
 109             return super.equals(obj);
 110         }
 111 
 112         /**
 113          * Returns a hash code value for this control type.
 114          *
 115          * @return a hash code value for this control type
 116          */
 117         @Override
 118         public final int hashCode() {
 119             return super.hashCode();
 120         }
 121 
 122         /**
 123          * Provides the {@code String} representation of the control type. This
 124          * {@code String} is the same name that was passed to the constructor.
 125          *
 126          * @return the control type name
 127          */
 128         @Override
 129         public final String toString() {
 130             return name;
 131         }
 132     }
 133 }
   1 /*
   2  * Copyright (c) 1999, 2020, 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


  49 
  50     /**
  51      * Constructs a control with the specified type.
  52      *
  53      * @param  type the kind of control desired
  54      */
  55     protected Control(Type type) {
  56         this.type = type;
  57     }
  58 
  59     /**
  60      * Obtains the control's type.
  61      *
  62      * @return the control's type
  63      */
  64     public Type getType() {
  65         return type;
  66     }
  67 
  68     /**
  69      * Returns a string representation of the control.
  70      *
  71      * @return a string representation of the control
  72      */
  73     @Override
  74     public String toString() {
  75         return String.format("%s control", getType());
  76     }
  77 
  78     /**
  79      * An instance of the {@code Type} class represents the type of the control.
  80      */
  81     public static class Type {
  82 
  83         /**
  84          * Type name.
  85          */
  86         private final String name;
  87 
  88         /**
  89          * Constructs a new control type with the name specified. The name
  90          * should be a descriptive string appropriate for labelling the control
  91          * in an application, such as "Gain" or "Balance".
  92          *
  93          * @param  name the name of the new control type
  94          */
  95         protected Type(String name) {


 103          * @param  obj the reference object with which to compare
 104          * @return {@code true} if the specified object is equal to this control
 105          *         type; {@code false} otherwise
 106          */
 107         @Override
 108         public final boolean equals(Object obj) {
 109             return super.equals(obj);
 110         }
 111 
 112         /**
 113          * Returns a hash code value for this control type.
 114          *
 115          * @return a hash code value for this control type
 116          */
 117         @Override
 118         public final int hashCode() {
 119             return super.hashCode();
 120         }
 121 
 122         /**
 123          * Returns type's name as the string representation of the control type.

 124          *
 125          * @return a string representation of the control type
 126          */
 127         @Override
 128         public final String toString() {
 129             return name;
 130         }
 131     }
 132 }
< prev index next >