1b39f051631250c49936a475d0e64584afb7f1b93Chet Haase/* 2b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * Copyright (C) 2011 The Android Open Source Project 3b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * 4b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * Licensed under the Apache License, Version 2.0 (the "License"); 5b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * you may not use this file except in compliance with the License. 6b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * You may obtain a copy of the License at 7b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * 8b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * http://www.apache.org/licenses/LICENSE-2.0 9b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * 10b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * Unless required by applicable law or agreed to in writing, software 11b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * distributed under the License is distributed on an "AS IS" BASIS, 12b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * See the License for the specific language governing permissions and 14b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * limitations under the License. 15b39f051631250c49936a475d0e64584afb7f1b93Chet Haase */ 16b39f051631250c49936a475d0e64584afb7f1b93Chet Haasepackage android.util; 17b39f051631250c49936a475d0e64584afb7f1b93Chet Haase 18b39f051631250c49936a475d0e64584afb7f1b93Chet Haaseimport android.util.Property; 19b39f051631250c49936a475d0e64584afb7f1b93Chet Haase 20b39f051631250c49936a475d0e64584afb7f1b93Chet Haase/** 21b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * An implementation of {@link android.util.Property} to be used specifically with fields of type 22b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * <code>int</code>. This type-specific subclass enables performance benefit by allowing 23b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * calls to a {@link #set(Object, Integer) set()} function that takes the primitive 24b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * <code>int</code> type and avoids autoboxing and other overhead associated with the 25b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * <code>Integer</code> class. 26b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * 27b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * @param <T> The class on which the Property is declared. 28b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * 29b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * @hide 30b39f051631250c49936a475d0e64584afb7f1b93Chet Haase */ 31b39f051631250c49936a475d0e64584afb7f1b93Chet Haasepublic abstract class IntProperty<T> extends Property<T, Integer> { 32b39f051631250c49936a475d0e64584afb7f1b93Chet Haase 33b39f051631250c49936a475d0e64584afb7f1b93Chet Haase public IntProperty(String name) { 34b39f051631250c49936a475d0e64584afb7f1b93Chet Haase super(Integer.class, name); 35b39f051631250c49936a475d0e64584afb7f1b93Chet Haase } 36b39f051631250c49936a475d0e64584afb7f1b93Chet Haase 37b39f051631250c49936a475d0e64584afb7f1b93Chet Haase /** 38b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * A type-specific override of the {@link #set(Object, Integer)} that is faster when dealing 39b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * with fields of type <code>int</code>. 40b39f051631250c49936a475d0e64584afb7f1b93Chet Haase */ 41b39f051631250c49936a475d0e64584afb7f1b93Chet Haase public abstract void setValue(T object, int value); 42b39f051631250c49936a475d0e64584afb7f1b93Chet Haase 43b39f051631250c49936a475d0e64584afb7f1b93Chet Haase @Override 44b39f051631250c49936a475d0e64584afb7f1b93Chet Haase final public void set(T object, Integer value) { 45c5d43f76fd7c3ccb91f1b75618a9c9e8f202505bLászló Dávid setValue(object, value.intValue()); 46b39f051631250c49936a475d0e64584afb7f1b93Chet Haase } 47b39f051631250c49936a475d0e64584afb7f1b93Chet Haase 48b39f051631250c49936a475d0e64584afb7f1b93Chet Haase}