-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] Intro GeneratorMetadata (stability index)
GeneratorMetadata offers an immutable object created via Builder pattern which allows generators to explicitly define their stability (stable, beta, experimental, deprecated) as well as a message to be shown during generation. This is a step toward: * Fleshing out the "Core" artifact (#845) * Providing a place to encapsulate feature-oriented metadata (#840) * Providing a means to communicate end of life scheduling (#116) This new structure, specifically the Stability property, allows us to offer future enhancements such as allowing users to filter down to only "Stable" generators via CLI, and eventually any compat table (see #503).
- Loading branch information
1 parent
561c1e0
commit 9a592da
Showing
8 changed files
with
311 additions
and
114 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
97 changes: 97 additions & 0 deletions
97
...openapi-generator-core/src/main/java/org/openapitools/codegen/meta/GeneratorMetadata.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,97 @@ | ||
package org.openapitools.codegen.meta; | ||
|
||
/** | ||
* Represents metadata about a generator. | ||
*/ | ||
public class GeneratorMetadata { | ||
private Stability stability; | ||
private String generationMessage; | ||
|
||
private GeneratorMetadata(Builder builder) { | ||
stability = builder.stability; | ||
generationMessage = builder.generationMessage; | ||
} | ||
|
||
/** | ||
* Creates a new builder object for {@link GeneratorMetadata}. | ||
* | ||
* @return A new builder instance. | ||
*/ | ||
public static Builder newBuilder() { | ||
return new Builder(); | ||
} | ||
|
||
/** | ||
* Creates a new builder object for {@link GeneratorMetadata}, accepting another instance from which to copy properties. | ||
* | ||
* @return A new builder instance, with values preset to those of 'copy'. | ||
*/ | ||
public static Builder newBuilder(GeneratorMetadata copy) { | ||
Builder builder = new Builder(); | ||
if (copy != null) { | ||
builder.stability = copy.getStability(); | ||
builder.generationMessage = copy.getGenerationMessage(); | ||
} | ||
return builder; | ||
} | ||
|
||
/** | ||
* Returns a message which can be displayed during generation. | ||
* | ||
* @return A message, if defined. | ||
*/ | ||
public String getGenerationMessage() { | ||
return generationMessage; | ||
} | ||
|
||
/** | ||
* Returns an enum describing the stability index of the generator. | ||
* | ||
* @return The defined stability index. | ||
*/ | ||
public Stability getStability() { | ||
return stability; | ||
} | ||
|
||
/** | ||
* {@code GeneratorMetadata} builder static inner class. | ||
*/ | ||
public static final class Builder { | ||
private Stability stability; | ||
private String generationMessage; | ||
|
||
private Builder() { | ||
} | ||
|
||
/** | ||
* Sets the {@code stability} and returns a reference to this Builder so that the methods can be chained together. | ||
* | ||
* @param stability the {@code stability} to set | ||
* @return a reference to this Builder | ||
*/ | ||
public Builder stability(Stability stability) { | ||
this.stability = stability; | ||
return this; | ||
} | ||
|
||
/** | ||
* Sets the {@code generationMessage} and returns a reference to this Builder so that the methods can be chained together. | ||
* | ||
* @param generationMessage the {@code generationMessage} to set | ||
* @return a reference to this Builder | ||
*/ | ||
public Builder generationMessage(String generationMessage) { | ||
this.generationMessage = generationMessage; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns a {@code GeneratorMetadata} built from the parameters previously set. | ||
* | ||
* @return a {@code GeneratorMetadata} built with parameters of this {@code GeneratorMetadata.Builder} | ||
*/ | ||
public GeneratorMetadata build() { | ||
return new GeneratorMetadata(this); | ||
} | ||
} | ||
} |
Oops, something went wrong.