Immutable
+ */ +public class Architecture { + private final String namespace; + private final int id; + private final String version; + private final String architecture; + + private Architecture(ArchitectureBuilder builder) { + this.namespace = builder.namespace; + this.id = builder.id; + this.version = builder.version; + this.architecture = builder.architecture; + } + + /** + * Returns the namespace of the architecture. + * @return the namespace of the architecture + */ + public String getNamespace() { + return namespace; + } + + /** + * Returns the id of the architecture. + * @return the id of the architecture + */ + public int getId() { + return id; + } + + /** + * Returns the version of the architecture as it should be reflected to the external world. + * @return the version of the architecture with dot format, e.g. 1.0.0 + */ + public String getDotVersion() { + return version; + } + + /** + * Returns the version of the architecture as it should be reflected to the MongoDB. + * @return the version of the architecture with hyphen format, e.g. 1-0-0 + */ + public String getMongoVersion() { + return version.replace('.', '-'); + } + + /** + * Returns the architecture in JSON format. + * @return the architecture in JSON format + */ + public String getArchitectureJson() { + return architecture; + } + + @Override + public boolean equals(Object o) { + if (o == null || getClass() != o.getClass()) return false; + Architecture that = (Architecture) o; + return id == that.id && Objects.equals(namespace, that.namespace) && Objects.equals(version, that.version) && Objects.equals(architecture, that.architecture); + } + + @Override + public int hashCode() { + return Objects.hash(namespace, id, version, architecture); + } + + @Override + public String toString() { + return "Architecture{" + + "namespace='" + namespace + '\'' + + ", id=" + id + + ", version='" + version + '\'' + + ", architecture='" + architecture + '\'' + + '}'; + } + + /** + * Builder class for creating an Architecture object. + */ + public static class ArchitectureBuilder { + private String namespace; + private int id; + private String version; + private String architecture; + + /** + * Sets the namespace of the architecture. + * @param namespace the namespace the architecture belongs to in CALM Hub + * @return the ArchitectureBuilder object + */ + public ArchitectureBuilder setNamespace(String namespace) { + this.namespace = namespace; + return this; + } + + /** + * Sets the id of the architecture. + * @param id as an integer known by CALM Hub + * @return the ArchitectureBuilder object + */ + public ArchitectureBuilder setId(int id) { + this.id = id; + return this; + } + + /** + * Sets the version of the architecture. + * @param version the version of the architecture, in dot format e.g. 1.0.0 + * @return the ArchitectureBuilder object + */ + public ArchitectureBuilder setVersion(String version) { + this.version = version; + return this; + } + + /** + * Sets the architecture in JSON format. + * @param architecture the architecture in JSON format + * @return the ArchitectureBuilder object + */ + public ArchitectureBuilder setArchitecture(String architecture) { + this.architecture = architecture; + return this; + } + + /** + * Builds the Architecture object. + * @return the Architecture object + */ + public Architecture build() { + return new Architecture(this); + } + } +} diff --git a/calm-hub/src/main/java/org/finos/calm/domain/Pattern.java b/calm-hub/src/main/java/org/finos/calm/domain/Pattern.java new file mode 100644 index 00000000..ec49b011 --- /dev/null +++ b/calm-hub/src/main/java/org/finos/calm/domain/Pattern.java @@ -0,0 +1,141 @@ +package org.finos.calm.domain; + +import java.util.Objects; + +/** + * Represents an architecture and the associated namespace, id, and version. + */ +public class Pattern { + private final String namespace; + private final int id; + private final String version; + private final String pattern; + + private Pattern(PatternBuilder builder) { + this.namespace = builder.namespace; + this.id = builder.id; + this.version = builder.version; + this.pattern = builder.pattern; + } + + /** + * Returns the namespace of the pattern. + * @return the namespace of the pattern + */ + public String getNamespace() { + return namespace; + } + + /** + * Returns the id of the pattern. + * @return the id of the pattern + */ + public int getId() { + return id; + } + + /** + * Returns the version of the pattern as it should be reflected to the external world. + * @return the version of the pattern with dot format, e.g. 1.0.0 + */ + public String getDotVersion() { + return version; + } + + /** + * Returns the version of the pattern as it should be reflected to the MongoDB. + * @return the version of the pattern with hyphen format, e.g. 1-0-0 + */ + public String getMongoVersion() { + return version.replace('.', '-'); + } + + /** + * Returns the pattern in JSON format. + * @return the pattern in JSON format + */ + public String getPatternJson() { + return pattern; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Pattern pattern1 = (Pattern) o; + return id == pattern1.id && Objects.equals(namespace, pattern1.namespace) && Objects.equals(version, pattern1.version) && Objects.equals(pattern, pattern1.pattern); + } + + @Override + public int hashCode() { + return Objects.hash(namespace, id, version, pattern); + } + + @Override + public String toString() { + return "Pattern{" + + "namespace='" + namespace + '\'' + + ", id=" + id + + ", version='" + version + '\'' + + ", pattern='" + pattern + '\'' + + '}'; + } + + /** + * Builder for the Pattern class. + */ + public static class PatternBuilder { + private String namespace; + private int id; + private String version; + private String pattern; + + /** + * Sets the namespace of the pattern. + * @param namespace the namespace of the pattern + * @return the PatternBuilder + */ + public PatternBuilder setNamespace(String namespace) { + this.namespace = namespace; + return this; + } + + /** + * Sets the id of the pattern. + * @param id the id of the pattern + * @return the PatternBuilder + */ + public PatternBuilder setId(int id) { + this.id = id; + return this; + } + + /** + * Sets the version of the pattern. + * @param version the version of the pattern + * @return the PatternBuilder + */ + public PatternBuilder setVersion(String version) { + this.version = version; + return this; + } + + /** + * Sets the pattern. + * @param pattern the pattern + * @return the PatternBuilder + */ + public PatternBuilder setPattern(String pattern) { + this.pattern = pattern; + return this; + } + + /** + * Builds the Pattern object. + * @return the Pattern object + */ + public Pattern build() { + return new Pattern(this); + } + } +} diff --git a/calm-hub/src/main/java/org/finos/calm/domain/ValueWrapper.java b/calm-hub/src/main/java/org/finos/calm/domain/ValueWrapper.java new file mode 100644 index 00000000..86f0db3c --- /dev/null +++ b/calm-hub/src/main/java/org/finos/calm/domain/ValueWrapper.java @@ -0,0 +1,20 @@ +package org.finos.calm.domain; + +import java.util.List; + +/** + * Wrapper class for a list of values, this is used to wrap a list of values and provide the option to paginate results later + * + * @param