@Override public NamePath getNamePath(String fullName) { return NamePath.dotted(fullName); }
@Override public String qualifiedName(NamePath namePath) { return namePath.toBackslashed(); }
@Override public String qualifiedName(NamePath namePath) { return namePath.toDotted(); }
private String topLevelEntryPointFileName(SurfaceNamer namer) { NamePath namePath = NamePath.dotted(namer.getVersionedDirectoryNamespace()); String name = namePath.getHead(); int lastUnderscoreIndex = name.lastIndexOf("_"); if (lastUnderscoreIndex > -1 && VersionMatcher.isVersion(name.substring(lastUnderscoreIndex + 1))) { name = name.substring(0, lastUnderscoreIndex); } String topLevelPath = namePath.withHead(name).toSlashed(); return String.format("%s.py", topLevelPath); }
/** * The type name of the Grpc service class This needs to match what Grpc generates for the * particular language. */ public String getGrpcServiceClassName(InterfaceModel apiInterface) { NamePath namePath = typeNameConverter.getNamePath(getTypeFormatter().getFullNameFor(apiInterface)); String grpcContainerName = publicClassName(Name.upperCamelKeepUpperAcronyms(namePath.getHead(), "Grpc")); String serviceClassName = publicClassName(Name.upperCamelKeepUpperAcronyms(apiInterface.getSimpleName(), "ImplBase")); return qualifiedName(namePath.withHead(grpcContainerName).append(serviceClassName)); }
private NamePath getGrpcClientTypeName(InterfaceModel apiInterface, String suffix) { NamePath namePath = getTypeNameConverter().getNamePath(getModelTypeFormatter().getFullNameFor(apiInterface)); String publicClassName = publicClassName(Name.upperCamelKeepUpperAcronyms(namePath.getHead(), suffix)); return namePath.withHead(publicClassName); }
@Override public TypeName getTypeName(ProtoElement elem) { return typeNameConverter.getTypeName( NamePath.dotted(elem.getFullName()).withUpperPieces().toDoubleColoned()); }
private ViewModel generateMetadataView( ApiModel model, PackageMetadataNamer metadataNamer, SurfaceNamer surfaceNamer) { List<PackageDependencyView> dependencies = ImmutableList.of( PackageDependencyView.create( "google/gax", packageConfig.gaxVersionBound(TargetLanguage.PHP)), PackageDependencyView.create( "google/protobuf", packageConfig.protoVersionBound(TargetLanguage.PHP))); String rootNamespace = NamePath.backslashed(surfaceNamer.getRootPackageName()).toDoubleBackslashed(); return metadataTransformer .generateMetadataView( metadataNamer, packageConfig, model, PACKAGE_FILE, "composer.json", TargetLanguage.PHP) .additionalDependencies(dependencies) .hasMultipleServices(model.hasMultipleServices()) .identifier(metadataNamer.getMetadataIdentifier()) .rootNamespace(rootNamespace) .build(); } }
/** Create a new NamePath where the head (the last piece) is replaced with the given newHead. */ public NamePath withHead(String newHead) { List<String> newPathPieces = new ArrayList<>(); newPathPieces.addAll(pathPieces); newPathPieces.set(pathPieces.size() - 1, newHead); return new NamePath(newPathPieces); }
/** Create a NamePath that is separated by dots. */ public static NamePath dotted(String... pieces) { return parse("\\.", pieces); }
@Override public NamePath getNamePath(String fullName) { return NamePath.doubleColoned(fullName); }
@Override public NamePath getNamePath(String fullName) { return NamePath.backslashed(fullName); }
@Override public String getFullyQualifiedStubType(InterfaceModel apiInterface) { NamePath namePath = getTypeNameConverter().getNamePath(getModelTypeFormatter().getFullNameFor(apiInterface)); return qualifiedName(namePath.append("Stub")); }
@Test public void testDottedPath() { NamePath path = NamePath.dotted("com.google.Foo"); assertThat(path.toDotted()).isEqualTo("com.google.Foo"); assertThat(path.toBackslashed()).isEqualTo("com\\google\\Foo"); assertThat(path.getHead()).isEqualTo("Foo"); assertThat(path.withHead("Bar").toDotted()).isEqualTo("com.google.Bar"); } }
/** * The type name of the Grpc service class This needs to match what Grpc generates for the * particular language. */ @Override public String getGrpcServiceClassName(InterfaceModel apiInterface) { String fullName = JavaModelTypeNameConverter.getGrpcTypeName( ((ProtoInterfaceModel) apiInterface).getInterface()) .getFullName(); NamePath namePath = getTypeNameConverter().getNamePath(fullName); String grpcContainerName = publicClassName(Name.upperCamelKeepUpperAcronyms(namePath.getHead(), "Grpc")); String serviceClassName = publicClassName(Name.upperCamelKeepUpperAcronyms(apiInterface.getSimpleName(), "ImplBase")); return qualifiedName(namePath.withHead(grpcContainerName).append(serviceClassName)); }
/** * The type name of the Grpc container class. This needs to match what Grpc generates for the * particular language. */ public String getGrpcContainerTypeName(InterfaceModel apiInterface) { NamePath namePath = typeNameConverter.getNamePath(getTypeFormatter().getFullNameFor(apiInterface)); String publicClassName = publicClassName(Name.upperCamelKeepUpperAcronyms(namePath.getHead(), "Grpc")); return qualifiedName(namePath.withHead(publicClassName)); }
/** * Create a new NamePath where the head (the last piece) is removed. If there is no last piece * this will return a new empty NamePath. */ public NamePath withoutHead() { List<String> newPathPieces = new ArrayList<>(); newPathPieces.addAll(pathPieces); if (!newPathPieces.isEmpty()) { newPathPieces.remove(newPathPieces.size() - 1); } return new NamePath(newPathPieces); }
public static NamePath backslashed(String... pieces) { return parse("\\\\", pieces); }
@Override public NamePath getNamePath(String fullName) { return NamePath.doubleColoned(fullName); }