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