Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
<groupId>com.azure</groupId>
<artifactId>azure-code-customization-parent</artifactId>
<version>1.0.0-beta.1</version> <!-- {x-version-update;com.azure:azure-code-customization-parent;current} -->
<relativePath>../../../parents/azure-code-customization-parent</relativePath>
</parent>

<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-servicebus-customization</artifactId>
<version>1.0.0-beta.1</version>
<modelVersion>4.0.0</modelVersion>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import com.azure.autorest.customization.ClassCustomization;
import com.azure.autorest.customization.Customization;
import com.azure.autorest.customization.LibraryCustomization;
import com.azure.autorest.customization.PackageCustomization;
import com.github.javaparser.ast.type.ClassOrInterfaceType;
import org.slf4j.Logger;

/**
* Code customization after code generation.
*/
public class ServiceBusCustomization extends Customization {
@Override
public void customize(LibraryCustomization customization, Logger logger) {
PackageCustomization fluentModelsPackage = customization.getPackage("com.azure.resourcemanager.servicebus.fluent.models");
// change base class from `ProxyResource` to `Resource`, to avoid breaking changes and compilation errors
customizeResourceBaseClass(fluentModelsPackage.getClass("SBTopicInner"));
customizeResourceBaseClass(fluentModelsPackage.getClass("SBSubscriptionInner"));
customizeResourceBaseClass(fluentModelsPackage.getClass("SBQueueInner"));
customizeResourceBaseClass(fluentModelsPackage.getClass("SBAuthorizationRuleInner"));
}

/**
* Customize the base class to be "com.azure.core.management.Resource".
*
* @param customization the customization for class
*/
private static void customizeResourceBaseClass(ClassCustomization customization) {
customization.customizeAst(ast -> {
ast.getClassByName(customization.getClassName()).ifPresent(clazz -> {
String resourceClassName = "com.azure.core.management.Resource";
ast.addImport(resourceClassName);
clazz.getExtendedTypes().clear();
clazz.addExtendedType(new ClassOrInterfaceType(null, "Resource"));
});
});
}
}
Loading