forked from opensearch-project/opensearch-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Invert abstractness of generated vs "handwritten" client classes (ope…
…nsearch-project#1170) * Invert abstractness of generated vs "handwritten" client classes Signed-off-by: Thomas Farr <[email protected]> * Address review comments Signed-off-by: Thomas Farr <[email protected]> --------- Signed-off-by: Thomas Farr <[email protected]> (cherry picked from commit 42e2928)
- Loading branch information
Showing
19 changed files
with
413 additions
and
141 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
71 changes: 71 additions & 0 deletions
71
java-codegen/src/main/java/org/opensearch/client/codegen/model/TypeParameterDefinition.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,71 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.client.codegen.model; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
import org.opensearch.client.codegen.utils.ObjectBuilderBase; | ||
import org.opensearch.client.codegen.utils.Strings; | ||
|
||
public final class TypeParameterDefinition { | ||
@Nonnull | ||
private final String name; | ||
@Nullable | ||
private final Type extendsType; | ||
|
||
private TypeParameterDefinition(Builder builder) { | ||
this.name = Strings.requireNonBlank(builder.name, "name must not be blank"); | ||
this.extendsType = builder.extendsType; | ||
} | ||
|
||
@Nonnull | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Nullable | ||
public Type getExtends() { | ||
return extendsType; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return name + (extendsType != null ? " extends " + extendsType : ""); | ||
} | ||
|
||
public static Builder builder() { | ||
return new Builder(); | ||
} | ||
|
||
public static final class Builder extends ObjectBuilderBase<TypeParameterDefinition, Builder> { | ||
private String name; | ||
private Type extendsType; | ||
|
||
private Builder() { | ||
super(TypeParameterDefinition::new); | ||
} | ||
|
||
@Override | ||
protected @Nonnull Builder self() { | ||
return this; | ||
} | ||
|
||
@Nonnull | ||
public Builder withName(@Nonnull String name) { | ||
this.name = Strings.requireNonBlank(name, "name must not be blank"); | ||
return this; | ||
} | ||
|
||
@Nonnull | ||
public Builder withExtends(@Nullable Type type) { | ||
this.extendsType = type; | ||
return this; | ||
} | ||
} | ||
} |
Oops, something went wrong.