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