DebugUtils.java revision 0f4ca634bbc43ddff900c35f7d2a43b55d8c830d
1cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn/* 2cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Copyright (C) 2011 The Android Open Source Project 3cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * 4cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Licensed under the Apache License, Version 2.0 (the "License"); 5cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * you may not use this file except in compliance with the License. 6cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * You may obtain a copy of the License at 7cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * 8cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * http://www.apache.org/licenses/LICENSE-2.0 9cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * 10cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * Unless required by applicable law or agreed to in writing, software 11cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * distributed under the License is distributed on an "AS IS" BASIS, 12cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * See the License for the specific language governing permissions and 14cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn * limitations under the License. 15cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 16cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 17ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikaspackage androidx.core.util; 18cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn 19ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP; 20c39d9c75590eca86a5e7e32a8824ba04a0d42e9bAlan Viverette 21ac5fe7c617c66850fff75a9fce9979c6e5674b0fAurimas Liutikasimport androidx.annotation.RestrictTo; 22c39d9c75590eca86a5e7e32a8824ba04a0d42e9bAlan Viverette 23cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn/** 24645e5c8aa6b31961c5f73f3d30bb5261d5e04aebKirill Grouchnikov * Helper for accessing features in {@link android.util.DebugUtils}. 250574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * 260574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov * @hide 27cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn */ 288e10080c914d1ad0784394fa3026b85535535847Aurimas Liutikas@RestrictTo(LIBRARY_GROUP) 29cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackbornpublic class DebugUtils { 300574ca37da4619afe4e26753f5a1b4de314b6565Svetoslav Ganov 31cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn public static void buildShortClassTag(Object cls, StringBuilder out) { 32cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (cls == null) { 33cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn out.append("null"); 34cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } else { 35cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn String simpleName = cls.getClass().getSimpleName(); 36cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (simpleName == null || simpleName.length() <= 0) { 37cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn simpleName = cls.getClass().getName(); 38cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn int end = simpleName.lastIndexOf('.'); 39cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn if (end > 0) { 40cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn simpleName = simpleName.substring(end+1); 41cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 42cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 43cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn out.append(simpleName); 44cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn out.append('{'); 45cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn out.append(Integer.toHexString(System.identityHashCode(cls))); 46cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 47cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn } 480f4ca634bbc43ddff900c35f7d2a43b55d8c830dJake Wharton 490f4ca634bbc43ddff900c35f7d2a43b55d8c830dJake Wharton private DebugUtils() { 500f4ca634bbc43ddff900c35f7d2a43b55d8c830dJake Wharton } 51cba2e2c881e8e16ea5025b564c94320174d65f01Dianne Hackborn} 52