Java tutorial
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); public class Main { private static final String TYPE_URL_PREFIX = "type.googleapis.com/"; /** * @return the class name of a proto from its type url. For example, return AesGcmKey * if the type url is type.googleapis.com/google.cloud.crypto.tink.AesGcmKey. * @throws IllegalArgumentException if {@code typeUrl} is in invalid format. */ public static String getProtoClassName(String typeUrl) throws IllegalArgumentException { validate(typeUrl); int dot = typeUrl.lastIndexOf("."); return typeUrl.substring(dot + 1); } /** * @throws IllegalArgumentException if {@code typeUrl} is in invalid format. */ public static void validate(String typeUrl) throws IllegalArgumentException { if (!typeUrl.startsWith(TYPE_URL_PREFIX)) { throw new IllegalArgumentException(String .format("Error: type URL %s is invalid; it must start with %s\n", typeUrl, TYPE_URL_PREFIX)); } } }