Home | History | Annotate | Download | only in state
      1 /*
      2  * Copyright (C) 2012 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 public class GLStringProperty extends GLAbstractAtomicProperty {
     20     private final String mDefaultValue;
     21     private String mCurrentValue;
     22 
     23     public GLStringProperty(GLStateType type, String defaultValue) {
     24         super(type);
     25 
     26         mDefaultValue = mCurrentValue = defaultValue;
     27     }
     28 
     29     @Override
     30     public boolean isDefault() {
     31         return mDefaultValue.equalsIgnoreCase(mCurrentValue);
     32     }
     33 
     34     @Override
     35     public void setValue(Object value) {
     36         if (value instanceof String) {
     37             mCurrentValue = (String) value;
     38         } else {
     39             throw new IllegalArgumentException("Attempt to set non-string value for " //$NON-NLS-1$
     40                     + getType());
     41         }
     42     }
     43 
     44     public void setValue(String value) {
     45         mCurrentValue = value;
     46     }
     47 
     48     @Override
     49     public Object getValue() {
     50         return mCurrentValue;
     51     }
     52 
     53     @Override
     54     public String getStringValue() {
     55         return mCurrentValue;
     56     }
     57 
     58     @Override
     59     public String toString() {
     60         return getType() + "=" + getStringValue(); //$NON-NLS-1$
     61     };
     62 }
     63