Home | History | Annotate | Download | only in common
      1 /*
      2  * Copyright (C) 2017 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 
     17 package android.inputmethodservice.cts.common;
     18 
     19 /**
     20  * Utility class to build Android's component name.
     21  */
     22 final class ComponentNameUtils {
     23 
     24     // This is utility class, can't instantiate.
     25     private ComponentNameUtils() {}
     26 
     27     /**
     28      * Build Android component name from {@code packageName} and {@code className}.
     29      * @param packageName package name of a component.
     30      * @param className class name of a component.
     31      * @return a component of {@code packageName/className} that can be used to specify component,
     32      *         for example, for {@code android.content.Intent}.
     33      */
     34     static String buildComponentName(final String packageName, final String className) {
     35         return packageName + "/" + (className.startsWith(packageName)
     36                 ? className.substring(packageName.length()) : className);
     37     }
     38 }
     39