Skip to content

Commit

Permalink
Add javadoc and clean up public interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
kstich committed Jun 27, 2023
1 parent f9dbf8f commit e28f64d
Show file tree
Hide file tree
Showing 78 changed files with 1,307 additions and 247 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,26 +62,60 @@ public static Optional<AwsArn> parse(String arn) {
.build());
}

/**
* Builder to create an {@link AwsArn} instance.
*
* @return returns a new Builder.
*/
public static Builder builder() {
return new Builder();
}

/**
* Gets the ARN's partition.
*
* @return returns the ARN's partition.
*/
public String getPartition() {
return partition;
}

/**
* Gets the ARN's service.
*
* @return returns the ARN's service.
*/

public String getService() {
return service;
}

/**
* Gets the ARN's region.
*
* @return returns the ARN's region.
*/

public String getRegion() {
return region;
}

/**
* Gets the ARN's accountId.
*
* @return returns the ARN's accountId.
*/

public String getAccountId() {
return accountId;
}

/**
* Gets the ARN's resource components.
*
* @return returns the ARN's resource components.
*/

public List<String> getResource() {
return resource;
}
Expand Down Expand Up @@ -126,6 +160,9 @@ public Builder toBuilder() {
.resource(resource);
}

/**
* A builder used to create an {@link AwsArn} class.
*/
public static final class Builder implements SmithyBuilder<AwsArn> {
private final BuilderRef<List<String>> resource = BuilderRef.forList();
private String partition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public final class AwsIsVirtualHostableS3Bucket extends LibraryFunction {
public static final String ID = "aws.isVirtualHostableS3Bucket";
private static final Definition DEFINITION = new Definition();

public AwsIsVirtualHostableS3Bucket(FunctionNode functionNode) {
private AwsIsVirtualHostableS3Bucket(FunctionNode functionNode) {
super(DEFINITION, functionNode);
}

Expand All @@ -32,6 +32,9 @@ public <T> T accept(ExpressionVisitor<T> visitor) {
return visitor.visitLibraryFunction(DEFINITION, getArguments());
}

/**
* A {@link FunctionDefinition} for the {@link AwsIsVirtualHostableS3Bucket} function.
*/
public static final class Definition implements FunctionDefinition {
@Override
public String getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import software.amazon.smithy.aws.rulesengine.language.functions.partition.PartitionDataProvider;
import software.amazon.smithy.aws.rulesengine.language.functions.partition.PartitionOutputs;
import software.amazon.smithy.aws.rulesengine.language.functions.partition.Partitions;
import software.amazon.smithy.rulesengine.language.evaluation.type.RecordType;
import software.amazon.smithy.rulesengine.language.evaluation.type.Type;
import software.amazon.smithy.rulesengine.language.evaluation.value.Value;
import software.amazon.smithy.rulesengine.language.syntax.Identifier;
Expand All @@ -45,7 +44,7 @@ public final class AwsPartition extends LibraryFunction {
private static final Definition DEFINITION = new Definition();
private static final PartitionData PARTITION_DATA = loadPartitionData();

public AwsPartition(FunctionNode functionNode) {
private AwsPartition(FunctionNode functionNode) {
super(DEFINITION, functionNode);
}

Expand Down Expand Up @@ -81,6 +80,9 @@ private static class PartitionData {
private final Map<String, Partition> regionMap = new HashMap<>();
}

/**
* A {@link FunctionDefinition} for the {@link AwsPartition} function.
*/
public static final class Definition implements FunctionDefinition {
@Override
public String getId() {
Expand All @@ -100,7 +102,7 @@ public Type getReturnType() {
type.put(DUAL_STACK_DNS_SUFFIX, Type.stringType());
type.put(SUPPORTS_DUAL_STACK, Type.booleanType());
type.put(SUPPORTS_FIPS, Type.booleanType());
return Type.optionalType(new RecordType(type));
return Type.optionalType(Type.recordType(type));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import software.amazon.smithy.rulesengine.language.evaluation.type.RecordType;
import software.amazon.smithy.rulesengine.language.evaluation.type.Type;
import software.amazon.smithy.rulesengine.language.evaluation.value.Value;
import software.amazon.smithy.rulesengine.language.syntax.Identifier;
Expand All @@ -35,7 +34,7 @@ public final class ParseArn extends LibraryFunction {

private static final Definition DEFINITION = new Definition();

public ParseArn(FunctionNode functionNode) {
private ParseArn(FunctionNode functionNode) {
super(DEFINITION, functionNode);
}

Expand All @@ -44,6 +43,9 @@ public <T> T accept(ExpressionVisitor<T> visitor) {
return visitor.visitLibraryFunction(DEFINITION, getArguments());
}

/**
* A {@link FunctionDefinition} for the {@link ParseArn} function.
*/
public static final class Definition implements FunctionDefinition {
@Override
public String getId() {
Expand All @@ -57,7 +59,7 @@ public List<Type> getArguments() {

@Override
public Type getReturnType() {
return Type.optionalType(new RecordType(MapUtils.of(
return Type.optionalType(Type.recordType(MapUtils.of(
PARTITION, Type.stringType(),
SERVICE, Type.stringType(),
REGION, Type.stringType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import software.amazon.smithy.utils.ToSmithyBuilder;

/**
* Describes an AWS partition, it's regions, and the outputs to be provided by the rule-set aws.partition function.
* Describes an AWS partition, its regions, and the outputs to be provided from the rule-set aws.partition function.
*/
@SmithyUnstableApi
public final class Partition implements ToSmithyBuilder<Partition>, FromSourceLocation, ToNode {
Expand All @@ -45,10 +45,21 @@ private Partition(Builder builder) {
this.outputs = builder.outputs;
}

/**
* Builder to create a {@link Partition} instance.
*
* @return returns a new Builder.
*/
public static Builder builder() {
return new Builder(SourceLocation.none());
}

/**
* Creates a {@link Partition} instance from the given Node information.
*
* @param node the node to deserialize.
* @return the created Partition.
*/
public static Partition fromNode(Node node) {
Builder builder = new Builder(node);
ObjectNode objectNode = node.expectObjectNode();
Expand All @@ -64,18 +75,38 @@ public static Partition fromNode(Node node) {
return builder.build();
}

/**
* Gets the ID of the partition.
*
* @return returns the partition's ID.
*/
public String getId() {
return id;
}

/**
* Gets the regular expression to match regions in this partition.
*
* @return returns the regular expression to match regions in this partition.
*/
public String getRegionRegex() {
return regionRegex;
}

/**
* Gets this partition's map of region names to region-specific overriding data.
*
* @return returns a map of region names to region-specific overriding data.
*/
public Map<String, RegionOverride> getRegions() {
return regions;
}

/**
* Gets the supported configuration output for this partition.
*
* @return returns the partition's configuration outputs.
*/
public PartitionOutputs getOutputs() {
return outputs;
}
Expand Down Expand Up @@ -128,6 +159,9 @@ public int hashCode() {
return Objects.hash(id, regionRegex, regions, outputs);
}

/**
* A builder used to create a {@link Partition} class.
*/
public static class Builder extends RulesComponentBuilder<Builder, Partition> {
private String id;
private String regionRegex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,21 @@ private PartitionOutputs(Builder builder) {
supportsDualStack = builder.supportsDualStack;
}

/**
* Builder to create a {@link PartitionOutputs} instance.
*
* @return returns a new Builder.
*/
public static Builder builder() {
return new Builder(SourceLocation.none());
}

/**
* Creates a {@link PartitionOutputs} instance from the given Node information.
*
* @param node the node to deserialize.
* @return the created PartitionOutputs.
*/
public static PartitionOutputs fromNode(Node node) {
Builder builder = new Builder(node);
ObjectNode objectNode = node.expectObjectNode();
Expand All @@ -66,22 +77,47 @@ public static PartitionOutputs fromNode(Node node) {
return builder.build();
}

/**
* Gets this partition's name.
*
* @return returns the partition's name.
*/
public Optional<String> getName() {
return Optional.ofNullable(name);
}

/**
* Gets this partition's default DNS suffix.
*
* @return returns the DNS suffix.
*/
public String getDnsSuffix() {
return dnsSuffix;
}

/**
* Gets this partition's dual stack DNS suffix.
*
* @return returns the DNS suffix for dual stack endpoints.
*/
public String getDualStackDnsSuffix() {
return dualStackDnsSuffix;
}

/**
* Returns true if the partition supports FIPS.
*
* @return returns true of FIPS is supported.
*/
public boolean supportsFips() {
return supportsFips;
}

/**
* Returns true if the partition supports dual stack.
*
* @return returns true of dual stack is supported.
*/
public boolean supportsDualStack() {
return supportsDualStack;
}
Expand Down Expand Up @@ -135,6 +171,9 @@ public int hashCode() {
return Objects.hash(name, dnsSuffix, dualStackDnsSuffix, supportsFips, supportsDualStack);
}

/**
* A builder used to create a {@link Partition} class.
*/
public static class Builder extends RulesComponentBuilder<Builder, PartitionOutputs> {
private String name;
private String dnsSuffix;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,21 @@ private Partitions(Builder builder) {
this.partitions = builder.partitions.copy();
}

/**
* Builder to create a {@link Partitions} instance.
*
* @return returns a new Builder.
*/
public static Builder builder() {
return new Builder(SourceLocation.none());
}

/**
* Creates a {@link Partitions} instance from the given Node information.
*
* @param node the node to deserialize.
* @return the created Partitions.
*/
public static Partitions fromNode(Node node) {
Builder builder = new Builder(node);
ObjectNode objNode = node.expectObjectNode();
Expand All @@ -54,10 +65,20 @@ public static Partitions fromNode(Node node) {
return builder.build();
}

/**
* Gets the version of the partitions file.
*
* @return returns the version of the partitions file.
*/
public String getVersion() {
return version;
}

/**
* Gets the list of loaded partitions.
*
* @return returns the list of partitions.
*/
public List<Partition> getPartitions() {
return partitions;
}
Expand Down Expand Up @@ -110,6 +131,9 @@ public String toString() {
+ '}';
}

/**
* A builder used to create a {@link Partitions} class.
*/
public static class Builder extends RulesComponentBuilder<Builder, Partitions> {
private String version;
private final BuilderRef<List<Partition>> partitions = BuilderRef.forList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,21 @@ private RegionOverride(SourceLocation sourceLocation) {
this.sourceLocation = sourceLocation;
}

/**
* Builder to create a {@link RegionOverride} instance.
*
* @return returns a new Builder.
*/
public static Builder builder() {
return new Builder(SourceLocation.none());
}

/**
* Creates a {@link RegionOverride} instance from the given Node information.
*
* @param node the node to deserialize.
* @return the created RegionOverride.
*/
public static RegionOverride fromNode(Node node) {
return new RegionOverride(node.getSourceLocation());
}
Expand Down
Loading

0 comments on commit e28f64d

Please sign in to comment.