Skip to content
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

Cleanup: No functional changes #32216

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ private ConfigModelId(String name, Version version) {

/**
* Create id with a name and version
*
* @param tagName Name of the id
* @param tagVersion Version of the id
* @return A ConfigModelId instance
* @return a ConfigModelId instance
*/
public static ConfigModelId fromNameAndVersion(String tagName, String tagVersion) {
return new ConfigModelId(tagName, Version.fromString(tagVersion));
Expand All @@ -34,7 +35,7 @@ public static ConfigModelId fromNameAndVersion(String tagName, String tagVersion
* Create id with given name, using default version 1.
*
* @param tagName Name of the id
* @return A ConfigModelId instance
* @return a ConfigModelId instance
*/
public static ConfigModelId fromName(String tagName) {
return new ConfigModelId(tagName, new Version(1));
Expand Down Expand Up @@ -68,6 +69,7 @@ public int hashCode() {

/**
* Return the XML element name.
*
* @return the name of the config model
*/
public String getName() {
Expand All @@ -76,17 +78,15 @@ public String getName() {

/**
* Return the XML element version.
*
* @return the version of the config model
*/
Version getVersion() {
return version;
}

private String toStringValue() {
StringBuilder sb = new StringBuilder();
sb.append(name);
sb.append(".");
sb.append(version);
return sb.toString();
return name + "." + version;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public static String nullIfEmpty(String attribute) {
*/
public static String getIdString(Element element) {
String idString = element.getAttribute("id");
if (idString == null || idString.trim().equals(""))
if (idString.trim().isEmpty())
idString = element.getAttribute(idReference);
if (idString == null || idString.trim().equals(""))
if (idString.trim().isEmpty())
idString = element.getAttribute("ident");
return idString;
}
Expand Down Expand Up @@ -119,7 +119,7 @@ public static boolean isReference(Element element) {
/**
* Creates a new XML document builder.
*
* @return A new DocumentBuilder instance, or null if we fail to get one.
* @return a new DocumentBuilder instance, or null if we fail to get one.
*/
public static synchronized DocumentBuilder getDocumentBuilder() {
try {
Expand Down Expand Up @@ -194,4 +194,5 @@ private static DocumentBuilderFactory createDocumentBuilderFactory() {
throw new RuntimeException(e);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
*/
public interface ConfigDefinitionStore {

/**
* Returns a config definition, or empty if the config definition is not found.
*/
/** Returns a config definition, or empty if the config definition is not found. */
Optional<ConfigDefinition> getConfigDefinition(ConfigDefinitionKey defKey);

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* A model graph contains the dependency graph of config models.
*
* @author Ulf Lilleengen
* @since 5.1
*/
public class ModelGraph {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
* constructor arguments.
*
* @author Ulf Lilleengen
* @since 5.1
*/
public class ModelGraphBuilder {

Expand Down Expand Up @@ -49,4 +48,5 @@ public ModelGraph build() {
}
return new ModelGraph(modelNodes, roots);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,14 @@ int addDependenciesFrom(List<ModelNode> modelNodes) {
}

private boolean isCollectionOf(Type type, Class<?> nodeClazz) {
if (type instanceof ParameterizedType) {
ParameterizedType t = (ParameterizedType) type;
// Note: IntelliJ says the following cannot be equal but that is wrong
if (type instanceof ParameterizedType t) {
return (t.getRawType().equals(java.util.Collection.class) && t.getActualTypeArguments().length == 1 && t.getActualTypeArguments()[0].equals(nodeClazz));
}
return false;
}

private boolean isCollection(Type type) {
if (type instanceof ParameterizedType) {
ParameterizedType t = (ParameterizedType) type;
// Note: IntelliJ says the following cannot be equal but that is wrong
if (type instanceof ParameterizedType t) {
return (t.getRawType().equals(java.util.Collection.class) && t.getActualTypeArguments().length == 1);
}
return false;
Expand All @@ -114,7 +110,7 @@ public MODEL createModel(ConfigModelContext context) {
if (params.length < 1 || ! params[0].equals(ConfigModelContext.class)) {
throw new IllegalArgumentException("Constructor for " + clazz.getName() + " must have as its first argument a " + ConfigModelContext.class.getName());
}
Object arguments[] = new Object[params.length];
Object[] arguments = new Object[params.length];
arguments[0] = context;
for (int i = 1; i < params.length; i++)
arguments[i] = findArgument(params[i]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,5 @@ public Optional<Service> getService(String configId) {
.filter(Service.class::isInstance)
.map(Service.class::cast);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public Host(String hostname, List<String> hostAliases, Optional<Flavor> flavor,

@Override
public String toString() {
return hostname + (aliases.size() > 0 ? " (aliases: " + aliases + ")" : "" ) +
(flavor.map(value -> " (flavor: " + value + ")").orElse(""));
return hostname + (!aliases.isEmpty() ? " (aliases: " + aliases + ")" : "" ) +
(flavor.map(value -> " (flavor: " + value + ")").orElse(""));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public Hosts(Collection<Host> hosts) {
private void validateAliases(Collection<Host> hosts) {
Set<String> aliases = new HashSet<>();
for (Host host : hosts) {
if (host.aliases().size() > 0) {
if (host.aliases().size() < 1)
if (!host.aliases().isEmpty()) {
if (host.aliases().isEmpty())
throw new IllegalArgumentException("Host '" + host.hostname() + "' must have at least one <alias> tag.");
for (String alias : host.aliases()) {
if (aliases.contains(alias))
Expand All @@ -65,7 +65,7 @@ public static Hosts readFrom(Reader hostsFile) {
Document doc = XmlHelper.getDocument(hostsFile);
for (Element hostE : XML.getChildren(doc.getDocumentElement(), "host")) {
String name = hostE.getAttribute("name");
if (name.equals("")) {
if (name.isEmpty()) {
throw new IllegalArgumentException("Missing 'name' attribute for host.");
}
if ("localhost".equals(name)) {
Expand Down Expand Up @@ -103,12 +103,12 @@ private static List<String> getHostAliases(NodeList hostAliases) {
}
if (! e.getNodeName().equals("alias")) {
throw new IllegalArgumentException("Unexpected tag: '" + e.getNodeName() + "' at node " +
XML.getNodePath(e, " > ") + ", expected 'alias'.");
XML.getNodePath(e, " > ") + ", expected 'alias'.");
}
String alias = e.getFirstChild().getNodeValue();
if ((alias == null) || (alias.equals(""))) {
if ((alias == null) || (alias.isEmpty())) {
throw new IllegalArgumentException("Missing value for the alias tag at node " +
XML.getNodePath(e, " > ") + "'.");
XML.getNodePath(e, " > ") + "'.");
}
aliases.add(alias);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

/**
* A host provisioner used when there is no hosts.xml file (using localhost as the only host)
* No state in this provisioner, i.e it does not know anything about the active
* No state in this provisioner, i.e. it does not know anything about the active
* application if one exists.
*
* @author hmusum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ public Builder withServices(String services) {
return this;
}

public Builder withSearchDefinition(String searchDefinition) {
this.schemas = List.of(searchDefinition);
public Builder withSchema(String schema) {
this.schemas = List.of(schema);
return this;
}

public Builder withSchemas(List<String> searchDefinition) {
this.schemas = List.copyOf(searchDefinition);
public Builder withSchemas(List<String> schemas) {
this.schemas = List.copyOf(schemas);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
*/
public class DataTypeRepo implements DataTypeCollection {

private Map<Integer, DataType> typeById = new LinkedHashMap<>();
private Map<String, DataType> typeByName = new LinkedHashMap<>();
private final Map<Integer, DataType> typeById = new LinkedHashMap<>();
private final Map<String, DataType> typeByName = new LinkedHashMap<>();

public DataType getDataType(String name) {
return typeByName.get(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* we want to end up with NewDocumentType as target type.
*
* @author arnej
**/
*/
public final class NewDocumentReferenceDataType extends DataType {

private final StructuredDataType target;
Expand Down Expand Up @@ -73,8 +73,7 @@ public Class<? extends ReferenceFieldValue> getValueClass() {
@Override
public boolean isValueCompatible(FieldValue value) {
var dt = value.getDataType();
if (dt instanceof ReferenceDataType) {
var refType = (ReferenceDataType) dt;
if (dt instanceof ReferenceDataType refType) {
var docTypeName = refType.getTargetType().getName();
return docTypeName.equals(target.getName());
}
Expand All @@ -83,8 +82,7 @@ public boolean isValueCompatible(FieldValue value) {

@Override
public boolean equals(Object rhs) {
if (rhs instanceof NewDocumentReferenceDataType) {
var other = (NewDocumentReferenceDataType) rhs;
if (rhs instanceof NewDocumentReferenceDataType other) {
return super.equals(other) && (temporary == other.temporary) && target.equals(other.target);
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Model for StructDataType declared in a specific document
*
* @author arnej
**/
*/
public final class OwnedStructDataType extends StructDataType implements OwnedType {

private final String ownerName;
Expand Down Expand Up @@ -53,4 +53,5 @@ public int getId() {
public String toString() {
return "{OwnedStructDataType "+uniqueName+" id="+getId()+" uid="+getUniqueId()+" enable override="+overrideId+"}";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Proxy for a struct type declared in a specific document
*
* @author arnej
**/
*/
public final class OwnedTemporaryType extends StructDataType implements OwnedType {

private final String ownerName;
Expand Down Expand Up @@ -38,4 +38,5 @@ public String getUniqueName() {
public String toString() {
return "{OwnedTemporaryType "+uniqueName+" id="+getId()+" uid="+getUniqueId()+"}";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
* API for a type declared in a specific document
*
* @author arnej
**/
*/
public interface OwnedType {

String getOwnerName();
String getUniqueName();
default int getUniqueId() {
return getUniqueName().hashCode();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* Proxy for an unknown type (must resolve to struct or document)
*
* @author arnej
**/
*/
public final class TemporaryUnknownType extends StructDataType {

public TemporaryUnknownType(String name) {
Expand All @@ -18,4 +18,5 @@ public TemporaryUnknownType(String name) {
public String toString() {
return "{TemporaryUnknownType "+getName()+" id="+getId()+"}";
}

}
Loading