Java Java String Format toJavaIdentifierString(String className)

Here you can find the source of toJavaIdentifierString(String className)

Description

to Java Identifier String

License

Apache License

Declaration

public static String toJavaIdentifierString(String className) 

Method Source Code

//package com.java2s;
/*/*from www. j  av a 2 s  .  c  om*/
 * 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 toJavaIdentifierString(String className) {
        // replace invalid characters with '_'
        int[] codePoints = className.codePoints().map(c -> Character.isJavaIdentifierPart(c) ? c : '_').toArray();
        return new String(codePoints, 0, codePoints.length);
    }
}

Related

  1. toJavaIdentifier(String str)
  2. toJavaIdentifier(String str)
  3. toJavaIdentifier(String str, String repl)
  4. toJavaIdentifier(String text, Boolean uppercaseFirst)
  5. toJavaIdentifierCamelCase(String tmp)
  6. toJavaImplClassName(String podName, String typeName)
  7. toJavaImplSig(String jsig)
  8. toJavaMethodName(String sqlNotation)
  9. toJavaMethodName(String... words)