blob: 9e21cedf1b4b92027441ee99a7d11bcb28565f7a [file] [log] [blame]
Chet Haaseb39f0512011-05-24 14:36:40 -07001/*
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
Chet Haaseb39f0512011-05-24 14:36:40 -070018/**
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
Chet Haase8240c97b2015-10-30 14:10:04 +000021 * calls to a {@link #setValue(Object, int) setValue()} function that takes the primitive
Chet Haaseb39f0512011-05-24 14:36:40 -070022 * <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.
Chet Haaseb39f0512011-05-24 14:36:40 -070026 */
27public abstract class IntProperty<T> extends Property<T, Integer> {
28
29 public IntProperty(String name) {
30 super(Integer.class, name);
31 }
32
33 /**
Chet Haase8240c97b2015-10-30 14:10:04 +000034 * A type-specific variant of {@link #set(Object, Integer)} that is faster when dealing
Chet Haaseb39f0512011-05-24 14:36:40 -070035 * with fields of type <code>int</code>.
36 */
37 public abstract void setValue(T object, int value);
38
39 @Override
40 final public void set(T object, Integer value) {
László Dávidc5d43f72012-11-23 00:26:22 +010041 setValue(object, value.intValue());
Chet Haaseb39f0512011-05-24 14:36:40 -070042 }
43
44}