generated from micronaut-projects/micronaut-project-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a common abstract class for type definitions (classes, records, i…
…nterfaces, enums) (#162) * Use a common abstract class for types (objects, records, interfaces, records) to reuse behavior * Add a method for getting this instance during building * Update graalvm * Remove getThis method and remove unneeded builder properties
- Loading branch information
1 parent
69e692b
commit f9c5304
Showing
8 changed files
with
103 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
sourcegen-model/src/main/java/io/micronaut/sourcegen/model/ObjectDefBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2017-2023 original authors | ||
* | ||
* 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 | ||
* | ||
* https://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. | ||
*/ | ||
package io.micronaut.sourcegen.model; | ||
|
||
import io.micronaut.core.annotation.Experimental; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* The abstract builder that is used for specific types: interfaces, classes, records or enums. | ||
* | ||
* @param <ThisType> The type of this builder | ||
* @author Andriy Dmytruk | ||
* @since 1.3 | ||
*/ | ||
@Experimental | ||
public sealed class ObjectDefBuilder<ThisType> | ||
extends AbstractElementBuilder<ThisType> | ||
permits ClassDef.ClassDefBuilder, InterfaceDef.InterfaceDefBuilder, | ||
RecordDef.RecordDefBuilder, EnumDef.EnumDefBuilder { | ||
|
||
protected final List<MethodDef> methods = new ArrayList<>(); | ||
protected final List<TypeDef> superinterfaces = new ArrayList<>(); | ||
|
||
protected ObjectDefBuilder(String name) { | ||
super(name); | ||
} | ||
|
||
public final ThisType addMethod(MethodDef method) { | ||
methods.add(method); | ||
return thisInstance; | ||
} | ||
|
||
public final ThisType addSuperinterface(TypeDef superinterface) { | ||
superinterfaces.add(superinterface); | ||
return thisInstance; | ||
} | ||
|
||
} |
Oops, something went wrong.