-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add missing Javadoc to API subprojects #2218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,28 +24,69 @@ | |
| import java.util.Objects; | ||
| import java.util.Set; | ||
|
|
||
| /** | ||
| * Utility class for creating extensible enum implementations. | ||
| * This class provides factory methods for creating instances of extensible enums | ||
| * such as Language, PathScope, and ProjectScope. | ||
| * | ||
| * @since 4.0.0 | ||
| */ | ||
| abstract class ExtensibleEnums { | ||
|
|
||
| /** | ||
| * Creates a new Language instance with the specified ID. | ||
| * | ||
| * @param id the identifier for the language | ||
| * @return a new Language instance | ||
| */ | ||
| static Language language(String id) { | ||
| return new DefaultLanguage(id); | ||
| } | ||
|
|
||
| /** | ||
| * Creates a new PathScope instance with the specified ID, project scope, and dependency scopes. | ||
| * | ||
| * @param id the identifier for the path scope | ||
| * @param projectScope the project scope associated with this path scope | ||
| * @param dependencyScopes the dependency scopes associated with this path scope | ||
| * @return a new PathScope instance | ||
| */ | ||
| static PathScope pathScope(String id, ProjectScope projectScope, DependencyScope... dependencyScopes) { | ||
| return new DefaultPathScope(id, projectScope, dependencyScopes); | ||
| } | ||
|
|
||
| /** | ||
| * Creates a new ProjectScope instance with the specified ID. | ||
| * | ||
| * @param id the identifier for the project scope | ||
| * @return a new ProjectScope instance | ||
| */ | ||
| static ProjectScope projectScope(String id) { | ||
| return new DefaultProjectScope(id); | ||
| } | ||
|
|
||
| /** | ||
| * Base implementation of the ExtensibleEnum interface. | ||
| * Provides common functionality for all extensible enum implementations. | ||
| */ | ||
| private static class DefaultExtensibleEnum implements ExtensibleEnum { | ||
|
|
||
| private final String id; | ||
|
|
||
| /** | ||
| * Creates a new DefaultExtensibleEnum with the specified ID. | ||
| * | ||
| * @param id the identifier for this enum value, must not be null | ||
| */ | ||
| DefaultExtensibleEnum(String id) { | ||
| this.id = Objects.requireNonNull(id); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the identifier for this enum value. | ||
| * | ||
| * @return the identifier | ||
| */ | ||
| public String id() { | ||
| return id; | ||
| } | ||
|
|
@@ -66,37 +107,73 @@ public String toString() { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * Implementation of the PathScope interface. | ||
| */ | ||
| private static class DefaultPathScope extends DefaultExtensibleEnum implements PathScope { | ||
| private final ProjectScope projectScope; | ||
| private final Set<DependencyScope> dependencyScopes; | ||
|
|
||
| /** | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. again not for this PR, but why is this all in one class? It feels like these should be split out to different classes
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This whole class is package protected and the classes are even private. Ideally they'd be refactored as records. And they'd become a one line record definition (we may need the toString though). |
||
| * Creates a new DefaultPathScope with the specified ID, project scope, and dependency scopes. | ||
| * | ||
| * @param id the identifier for this path scope | ||
| * @param projectScope the project scope associated with this path scope, must not be null | ||
| * @param dependencyScopes the dependency scopes associated with this path scope, must not be null | ||
| */ | ||
| DefaultPathScope(String id, ProjectScope projectScope, DependencyScope... dependencyScopes) { | ||
| super(id); | ||
| this.projectScope = Objects.requireNonNull(projectScope); | ||
| this.dependencyScopes = | ||
| Collections.unmodifiableSet(new HashSet<>(Arrays.asList(Objects.requireNonNull(dependencyScopes)))); | ||
| } | ||
|
|
||
| /** | ||
| * Returns the project scope associated with this path scope. | ||
| * | ||
| * @return the project scope | ||
| */ | ||
| @Override | ||
| public ProjectScope projectScope() { | ||
| return projectScope; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the dependency scopes associated with this path scope. | ||
| * | ||
| * @return an unmodifiable set of dependency scopes | ||
| */ | ||
| @Override | ||
| public Set<DependencyScope> dependencyScopes() { | ||
| return dependencyScopes; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Implementation of the ProjectScope interface. | ||
| */ | ||
| private static class DefaultProjectScope extends DefaultExtensibleEnum implements ProjectScope { | ||
|
|
||
| /** | ||
| * Creates a new DefaultProjectScope with the specified ID. | ||
| * | ||
| * @param id the identifier for this project scope | ||
| */ | ||
| DefaultProjectScope(String id) { | ||
| super(id); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Implementation of the Language interface. | ||
| */ | ||
| private static class DefaultLanguage extends DefaultExtensibleEnum implements Language { | ||
|
|
||
| /** | ||
| * Creates a new DefaultLanguage with the specified ID. | ||
| * | ||
| * @param id the identifier for this language | ||
| */ | ||
| DefaultLanguage(String id) { | ||
| super(id); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR, but I wonder if we should have a different name here to avoid confusion with Java enums, which these aren't