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 Haase/** 19b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * An implementation of {@link android.util.Property} to be used specifically with fields of type 20b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * <code>int</code>. This type-specific subclass enables performance benefit by allowing 218240c97b01c367e59f79a73952db6f7e2d4f657dChet Haase * calls to a {@link #setValue(Object, int) setValue()} function that takes the primitive 22b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * <code>int</code> type and avoids autoboxing and other overhead associated with the 23b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * <code>Integer</code> class. 24b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * 25b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * @param <T> The class on which the Property is declared. 26b39f051631250c49936a475d0e64584afb7f1b93Chet Haase */ 27b39f051631250c49936a475d0e64584afb7f1b93Chet Haasepublic abstract class IntProperty<T> extends Property<T, Integer> { 28b39f051631250c49936a475d0e64584afb7f1b93Chet Haase 29b39f051631250c49936a475d0e64584afb7f1b93Chet Haase public IntProperty(String name) { 30b39f051631250c49936a475d0e64584afb7f1b93Chet Haase super(Integer.class, name); 31b39f051631250c49936a475d0e64584afb7f1b93Chet Haase } 32b39f051631250c49936a475d0e64584afb7f1b93Chet Haase 33b39f051631250c49936a475d0e64584afb7f1b93Chet Haase /** 348240c97b01c367e59f79a73952db6f7e2d4f657dChet Haase * A type-specific variant of {@link #set(Object, Integer)} that is faster when dealing 35b39f051631250c49936a475d0e64584afb7f1b93Chet Haase * with fields of type <code>int</code>. 36b39f051631250c49936a475d0e64584afb7f1b93Chet Haase */ 37b39f051631250c49936a475d0e64584afb7f1b93Chet Haase public abstract void setValue(T object, int value); 38b39f051631250c49936a475d0e64584afb7f1b93Chet Haase 39b39f051631250c49936a475d0e64584afb7f1b93Chet Haase @Override 40b39f051631250c49936a475d0e64584afb7f1b93Chet Haase final public void set(T object, Integer value) { 41c5d43f76fd7c3ccb91f1b75618a9c9e8f202505bLászló Dávid setValue(object, value.intValue()); 42b39f051631250c49936a475d0e64584afb7f1b93Chet Haase } 43b39f051631250c49936a475d0e64584afb7f1b93Chet Haase 44b39f051631250c49936a475d0e64584afb7f1b93Chet Haase}