1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ide.eclipse.gltrace.state; 18 19 20 /** Properties that hold boolean values. */ 21 public final class GLBooleanProperty extends GLAbstractAtomicProperty { 22 private final Boolean mDefaultValue; 23 private Boolean mCurrentValue; 24 25 public GLBooleanProperty(GLStateType name, Boolean defaultValue) { 26 super(name); 27 28 mDefaultValue = mCurrentValue = defaultValue; 29 } 30 31 @Override 32 public boolean isDefault() { 33 return mDefaultValue == mCurrentValue; 34 } 35 36 public void setValue(Boolean newValue) { 37 mCurrentValue = newValue; 38 } 39 40 @Override 41 public String getStringValue() { 42 return mCurrentValue.toString(); 43 } 44 45 @Override 46 public String toString() { 47 return getType() + "=" + getStringValue(); //$NON-NLS-1$ 48 } 49 50 @Override 51 public void setValue(Object value) { 52 if (value instanceof Boolean) { 53 mCurrentValue = (Boolean) value; 54 } else { 55 throw new IllegalArgumentException("Attempt to set non-boolean value for " //$NON-NLS-1$ 56 + getType()); 57 } 58 } 59 60 @Override 61 public Object getValue() { 62 return mCurrentValue; 63 } 64 } 65