Skip to content

Commit

Permalink
style(lint): Lint fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Genov <[email protected]>
  • Loading branch information
Michaelpalacce committed Jan 14, 2025
1 parent df3e9fb commit 082ebf1
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .github/linters/sun_checks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ https://www.oracle.com/java/technologies/javase/codeconventions-contents.html

<!-- Checks for class design -->
<!-- See https://checkstyle.org/config_design.html -->
<module name="DesignForExtension" />
<!-- Uncomment later -->
<!-- <module name="DesignForExtension" /> -->
<module name="FinalClass" />
<module name="HideUtilityClassConstructor" />
<module name="InterfaceIsType" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,22 @@
import java.util.Collections;
import java.util.List;

import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
* VraNgCloudAccount is the Aria Automation > Infrastructire > Cloud Account
* representation.
*/
public class VraNgCloudAccount {
/**
* @param Prime Number 17.
*/
private static final int PRIME_NUMBER_17 = 17;

/**
* @param Prime Number 31.
*/
private static final int PRIME_NUMBER_31 = 31;
private final String id;
private final String name;
private final String type;
Expand Down Expand Up @@ -95,10 +106,10 @@ public boolean equals(Object obj) {
*/
@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + (name == null ? 0 : name.hashCode());
hash = 31 * hash + (type == null ? 0 : type.hashCode());
return hash;
return new HashCodeBuilder(PRIME_NUMBER_17, PRIME_NUMBER_31)
.append(name)
.append(type)
.toHashCode();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.List;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({"items"})
@JsonPropertyOrder({ "items" })
public class VraNgOrganizations implements Serializable {
private static final long serialVersionUID = -3313748896114761975L;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,21 @@
*/
package com.vmware.pscoe.iac.artifact.aria.models;

import org.apache.commons.lang3.builder.HashCodeBuilder;

/**
* Aria automation > Infrastructure > Region.
*/
public class VraNgRegion {
/**
* @param Prime Number 17.
*/
private static final int PRIME_NUMBER_17 = 17;

/**
* @param Prime Number 31.
*/
private static final int PRIME_NUMBER_31 = 31;

private final String id;
private final String cloudAccountId;
Expand Down Expand Up @@ -59,13 +70,12 @@ public boolean equals(Object obj) {
}

/**
* @return the hash of the instance
* @return the hashcode representation of the object
*/
@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + (cloudAccountId == null ? 0 : cloudAccountId.hashCode());

return hash;
return new HashCodeBuilder(PRIME_NUMBER_17, PRIME_NUMBER_31)
.append(cloudAccountId)
.toHashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,23 +154,26 @@ private String getNextVersion(String version) {
Matcher major = Pattern.compile("([0-9]+)").matcher(version);
Matcher majorMinor = Pattern.compile("([0-9]+)\\.([0-9]+)").matcher(version);
Matcher majorMinorPatch = Pattern.compile("([0-9]+)\\.([0-9]+)\\.([0-9]+)").matcher(version);
int thirdSegment = 3;
int secondSegment = 2;
int firstSegment = 1;

if (majorMinorPatch.matches()) {
logger.debug("Detected version pattern MAJOR.MINOR.PATCH from {} with incrementable segment '{}'", version,
majorMinorPatch.group(3));
majorMinorPatch.group(thirdSegment));
// increment the patch segment
return majorMinorPatch.group(1) + "." + majorMinorPatch.group(2) + "."
+ (Integer.parseInt(majorMinorPatch.group(3)) + 1);
return majorMinorPatch.group(firstSegment) + "." + majorMinorPatch.group(secondSegment) + "."
+ (Integer.parseInt(majorMinorPatch.group(thirdSegment)) + 1);
} else if (majorMinor.matches()) {
logger.debug("Detected version pattern MAJOR.MINOR from '{}' with incrementable segment '{}'", version,
majorMinor.group(2));
majorMinor.group(secondSegment));
// increment the minor segment
return majorMinor.group(1) + "." + (Integer.parseInt(majorMinor.group(2)) + 1);
return majorMinor.group(firstSegment) + "." + (Integer.parseInt(majorMinor.group(secondSegment)) + 1);
} else if (major.matches()) {
logger.debug("Detected version pattern MAJOR from '{}' with incrementable segment '{}'", version,
major.group(1));
major.group(firstSegment));
// increment the major segment
return Integer.toString(Integer.parseInt(major.group(1)) + 1);
return Integer.toString(Integer.parseInt(major.group(firstSegment)) + 1);
} else {
logger.debug("Could not determine version pattern from {}", version);
return getDateVersion();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,31 @@
import java.util.List;
import java.util.Optional;

/**
* VraNgIntegrationUtils is used to get the default VraNgIntegration.
*/
public class VraNgIntegrationUtils {
public static final String DEFAULT_INTEGRATION_NAME = "embedded-VRO";
private static final VraNgIntegrationUtils instance = new VraNgIntegrationUtils();

private Optional<VraNgIntegration> retVal = Optional.empty();

private VraNgIntegrationUtils() {}
private VraNgIntegrationUtils() {
}

public static VraNgIntegrationUtils getInstance() {
return instance;
}

public VraNgIntegration getDefaultVraIntegration(RestClientVraNg restClient) {
if(this.retVal.isPresent()) {
if (this.retVal.isPresent()) {
return this.retVal.get();
}

List<VraNgIntegration> integrations = restClient.getVraWorkflowIntegrations();

this.retVal = integrations.stream().filter(integration -> DEFAULT_INTEGRATION_NAME.equalsIgnoreCase(integration.getName()))
this.retVal = integrations.stream()
.filter(integration -> DEFAULT_INTEGRATION_NAME.equalsIgnoreCase(integration.getName()))
.findFirst();

return this.retVal.orElse(new VraNgIntegration());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import java.util.Properties;

public class ConfigurationAbx extends ConfigurationVraNg {

private final static Logger logger = LoggerFactory.getLogger(ConfigurationAbx.class);
private static final Logger logger = LoggerFactory.getLogger(ConfigurationAbx.class);

protected ConfigurationAbx(Properties props) {
super(PackageType.ABX, props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.nio.file.Paths;

public class CustomResourceFsMocks extends VraNgFsMock {
private final static String WORKDIR = "custom-resources";
private static final String WORKDIR = "custom-resources";

public CustomResourceFsMocks(File tempDir) {
super(tempDir);
Expand Down

0 comments on commit 082ebf1

Please sign in to comment.