Home | History | Annotate | Download | only in util
      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 package android.util;
     17 
     18 import android.util.Property;
     19 
     20 /**
     21  * An implementation of {@link android.util.Property} to be used specifically with fields of type
     22  * <code>float</code>. This type-specific subclass enables performance benefit by allowing
     23  * calls to a {@link #set(Object, Float) set()} function that takes the primitive
     24  * <code>float</code> type and avoids autoboxing and other overhead associated with the
     25  * <code>Float</code> class.
     26  *
     27  * @param <T> The class on which the Property is declared.
     28  *
     29  * @hide
     30  */
     31 public abstract class FloatProperty<T> extends Property<T, Float> {
     32 
     33     public FloatProperty(String name) {
     34         super(Float.class, name);
     35     }
     36 
     37     /**
     38      * A type-specific override of the {@link #set(Object, Float)} that is faster when dealing
     39      * with fields of type <code>float</code>.
     40      */
     41     public abstract void setValue(T object, float value);
     42 
     43     @Override
     44     final public void set(T object, Float value) {
     45         setValue(object, value);
     46     }
     47 
     48 }