Java Class Name Clean classNameWithoutGeneric(String s)

Here you can find the source of classNameWithoutGeneric(String s)

Description

class Name Without Generic

License

Apache License

Declaration

public static String classNameWithoutGeneric(String s) 

Method Source Code

//package com.java2s;
/*/*from  w w  w . j ava2  s  . c  om*/
 appinventor-java-translation

 Originally authored by Joshua Swank at the University of Alabama
 Work supported in part by NSF award #0702764 and a Google 2011 CS4HS award

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */

public class Main {
    public static String classNameWithoutGeneric(String s) {
        return removeGeneric(lastIdentifier(s));
    }

    public static String removeGeneric(String s) {
        if (s.contains("<"))
            return s.substring(0, s.lastIndexOf("<"));
        else
            return s;
    }

    public static String lastIdentifier(String s) {
        if (s.contains("."))
            return s.substring(s.lastIndexOf(".") + 1);
        else
            return s;
    }
}

Related

  1. classNameFromQualifiedClassName(String qualifiedName)
  2. classNameFromQualifiedName(String qualifiedCalssName)
  3. classNameOnly(Object o)
  4. classNameWithoutPackage(Class objectClass)
  5. classNameWithoutPackage(Class objectClass)
  6. classNameWithoutPackage(String classname)
  7. classNameWithoutPackageQualifiers(String className)