return null;
}
- var validationResultBuilder = new StringBuilder();
-
- validationResultBuilder.append(initialIndentation);
- validationResultBuilder.append("field \"");
- validationResultBuilder.append(getName());
- validationResultBuilder.append("\" type \"");
- validationResultBuilder.append(field.getType().getName());
- validationResultBuilder.append("\" value \"");
- validationResultBuilder.append(parameterValue);
- validationResultBuilder.append("\" ");
- validationResultBuilder.append(getStatus());
- validationResultBuilder.append(", ");
- validationResultBuilder.append(message);
- validationResultBuilder.append('\n');
-
- return validationResultBuilder.toString();
+ return initialIndentation
+ + "field \"" + getName()
+ + "\" type \"" + field.getType().getName()
+ + "\" value \"" + parameterValue
+ + "\" " + getStatus()
+ + ", "
+ + message
+ + '\n';
}
}
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
+ @ToString
public static class MyObject {
private int id;
public MyObject(int id) {
this.id = id;
}
-
- @Override
- public String toString() {
- return "MyObject [id=" + id + "]";
- }
}
private static class MyMap {
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.lang.reflect.GenericArrayType;
import java.util.LinkedList;
import java.util.TreeMap;
+import lombok.ToString;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* Used to verify that no fields are exposed.
*/
+ @ToString
public static class Data {
private int id;
public String text;
public void setText(String text) {
this.text = text;
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + ", text=" + text + "]";
- }
}
+ @ToString(callSuper = true)
public static class Derived extends Data {
protected String value;
public void setValue(String value) {
this.value = value;
}
-
- @Override
- public String toString() {
- return "Derived [value=" + value + ", " + super.toString() + "]";
- }
}
/**
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.google.gson.reflect.TypeToken;
import java.util.ArrayList;
import java.util.List;
+import lombok.ToString;
import org.junit.Test;
import org.onap.policy.common.gson.annotation.GsonJsonIgnore;
import org.onap.policy.common.gson.annotation.GsonJsonProperty;
return text.replaceFirst("@\\w+", "@");
}
+ @ToString
private static class Data {
@GsonJsonProperty("my-id")
private int id;
public void setId(int id) {
this.id = id;
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + ", text=" + text + "]";
- }
}
+ @ToString(callSuper = true)
private static class Derived extends Data {
// not serialized
private String unserialized;
-
- @Override
- public String toString() {
- return "Derived [unserialized=" + unserialized + ", toString()=" + super.toString() + "]";
- }
}
private static class DataList {
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.Map;
import java.util.TreeMap;
import javax.ws.rs.core.MediaType;
+import lombok.ToString;
import org.junit.Test;
import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter;
import org.onap.policy.common.gson.annotation.GsonJsonAnySetter;
/**
* This class includes all policy-specific gson annotations.
*/
+ @ToString
public static class Data {
protected int id;
props.put(name, value);
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + ", value=" + value + ", props=" + props + "]";
- }
}
private static class MyMap {
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import com.google.gson.reflect.TypeToken;
import java.util.Map;
import java.util.TreeMap;
+import lombok.ToString;
import org.junit.Test;
import org.onap.policy.common.gson.annotation.GsonJsonAnyGetter;
import org.onap.policy.common.gson.annotation.GsonJsonAnySetter;
assertEquals("{'id':500,'nested':{'value':'bye bye'}}".replace('\'', '"'), result);
}
+ @ToString
protected static class Data {
private int id;
private String text;
public void unused(String text) {
// do nothing
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + ", text=" + text + "]";
- }
}
+ @ToString(callSuper = true)
protected static class Derived extends Data {
// overrides private field from Data
map.put(key, value);
}
-
- @Override
- public String toString() {
- return "Derived [text=" + text + ", map=" + map + ", toString()=" + super.toString() + "]";
- }
}
/**
/**
* Used to test serialization of non-static nested classes.
*/
+ @ToString
protected static class Container {
private int id;
private Nested nested;
return nested;
}
- @Override
- public String toString() {
- return "Container [id=" + id + ", nested=" + nested + "]";
- }
-
+ @ToString
protected class Nested {
private String value;
public String getValue() {
return value;
}
-
- @Override
- public String toString() {
- return "Nested [value=" + value + "]";
- }
}
}
}
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import lombok.ToString;
/**
* Factory used with test Data.
/**
* Object handled by this factory.
*/
+ @ToString
public static class Data {
private int id;
public void setId(int id) {
this.id = id;
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + "]";
- }
}
/**
* Object derived from Data.
*/
+ @ToString(callSuper = true)
public static class DerivedData extends Data {
private String text;
public void setText(String text) {
this.text = text;
}
-
- @Override
- public String toString() {
- return "DerivedData [text=" + text + ", toString()=" + super.toString() + "]";
- }
}
/**
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
+import lombok.ToString;
import org.junit.Before;
import org.junit.Test;
assertEquals("read text", data);
}
+ @ToString
private static class Data {
private String id;
private String value;
this.id = id;
this.value = value;
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + ", value=" + value + "]";
- }
}
private abstract static class NamedSer implements Serializer {
* ============LICENSE_START=======================================================
* Integrity Monitor
* ================================================================================
- * Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2021 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2020 Bell Canada. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
return null;
}
- final StringBuilder b = new StringBuilder();
-
- b.append(sm.getAdminState());
- b.append(',');
- b.append(sm.getOpState());
- b.append(',');
- b.append(sm.getAvailStatus());
- b.append(',');
- b.append(sm.getStandbyStatus());
-
- return b.toString();
+ return sm.getAdminState()
+ + ',' + sm.getOpState()
+ + ',' + sm.getAvailStatus()
+ + ',' + sm.getStandbyStatus();
}
}
@Override
public String toString() {
- return "IndexedDmaapTopicSinkFactory []";
+ return "IndexedDmaapTopicSinkFactory " + dmaapTopicWriters.keySet();
}
}
@Override
public String toString() {
- return "IndexedDmaapTopicSourceFactory []";
+ return "IndexedDmaapTopicSourceFactory " + dmaapTopicSources.keySet();
}
}
@Override
public String toString() {
- return "IndexedUebTopicSinkFactory []";
+ return "IndexedUebTopicSinkFactory " + uebTopicSinks.keySet();
}
}
@Override
public String toString() {
- return "IndexedUebTopicSourceFactory []";
+ return "IndexedUebTopicSourceFactory " + uebTopicSources.keySet();
}
}
@Override
public String toString() {
- var builder = new StringBuilder();
- builder.append("InlineUebTopicSink [getTopicCommInfrastructure()=").append(getTopicCommInfrastructure())
- .append(", toString()=").append(super.toString()).append("]");
- return builder.toString();
+ return "InlineUebTopicSink [getTopicCommInfrastructure()=" + getTopicCommInfrastructure() + ", toString()="
+ + super.toString() + "]";
}
@Override
@Override
public String toString() {
- var builder = new StringBuilder();
- builder.append("SingleThreadedDmaapTopicSource [userName=").append(userName).append(", password=")
- .append((password == null || password.isEmpty()) ? "-" : password.length())
- .append(", getTopicCommInfrastructure()=").append(getTopicCommInfrastructure()).append(", toString()=")
- .append(super.toString()).append("]");
- return builder.toString();
+ return "SingleThreadedDmaapTopicSource [userName=" + userName
+ + ", password=" + (password == null || password.isEmpty() ? "-" : password.length())
+ + ", getTopicCommInfrastructure()=" + getTopicCommInfrastructure()
+ + ", toString()=" + super.toString() + "]";
}
@Override
public String toString() {
- var builder = new StringBuilder();
- builder.append("SingleThreadedUebTopicSource [getTopicCommInfrastructure()=")
- .append(getTopicCommInfrastructure()).append(", toString()=").append(super.toString()).append("]");
- return builder.toString();
+ return "SingleThreadedUebTopicSource [getTopicCommInfrastructure()=" + getTopicCommInfrastructure()
+ + ", toString()=" + super.toString() + "]";
}
}
import javax.ws.rs.client.InvocationCallback;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Response;
+import lombok.ToString;
import org.apache.commons.lang3.StringUtils;
import org.glassfish.jersey.client.ClientProperties;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
/**
* Http Client implementation using a Jersey Client.
*/
+@ToString
public class JerseyClient implements HttpClient {
private static final Pattern COMMA_PAT = Pattern.compile(",");
return baseUrl;
}
- @Override
- public String toString() {
- var builder = new StringBuilder();
- builder.append("JerseyClient [name=");
- builder.append(name);
- builder.append(", https=");
- builder.append(https);
- builder.append(", selfSignedCerts=");
- builder.append(selfSignedCerts);
- builder.append(", hostname=");
- builder.append(hostname);
- builder.append(", port=");
- builder.append(port);
- builder.append(", basePath=");
- builder.append(basePath);
- builder.append(", userName=");
- builder.append(userName);
- builder.append(", password=");
- builder.append(password);
- builder.append(", client=");
- builder.append(client);
- builder.append(", baseUrl=");
- builder.append(baseUrl);
- builder.append(", alive=");
- builder.append(alive);
- builder.append("]");
- return builder.toString();
- }
-
private Builder getBuilder(String path, Map<String, Object> headers) {
var builder = getWebTarget().path(path).request();
for (Entry<String, Object> header : headers.entrySet()) {
package org.onap.policy.common.endpoints.http.server;
+import java.util.Arrays;
import java.util.List;
import java.util.Properties;
+import java.util.stream.Collectors;
+import lombok.ToString;
import org.onap.policy.common.endpoints.http.server.aaf.AafAuthFilter;
import org.onap.policy.common.endpoints.parameters.RestServerParameters;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
*
* @author Ram Krishna Verma (ram.krishna.verma@est.tech)
*/
+@ToString
public class RestServer extends ServiceManagerContainer {
/**
* @return the provider class names
*/
private String getProviderClassNames(Class<?>[] jaxrsProviders) {
- var names = new StringBuilder();
-
- for (Class<?> prov : jaxrsProviders) {
- if (names.length() > 0) {
- names.append(',');
- }
-
- names.append(prov.getName());
- }
-
- return names.toString();
+ return String.join(",", Arrays.stream(jaxrsProviders).map(Class::getName).collect(Collectors.toList()));
}
private String getValue(final String value) {
return value;
}
- @Override
- public String toString() {
- return "RestServer [servers=" + servers + "]";
- }
-
/**
* Factory used to access objects.
*/
@Override
public String toString() {
- var builder = new StringBuilder();
- builder.append("JettyJerseyServer [Jerseyservlets=").append(servlets).append(", swaggerId=").append(swaggerId)
- .append(", toString()=").append(super.toString()).append("]");
- return builder.toString();
+ return "JettyJerseyServer [Jerseyservlets=" + servlets
+ + ", swaggerId=" + swaggerId
+ + ", toString()=" + super.toString()
+ + "]";
}
}
import java.util.EnumSet;
import javax.servlet.DispatcherType;
+import lombok.ToString;
import org.eclipse.jetty.security.ConstraintMapping;
import org.eclipse.jetty.security.ConstraintSecurityHandler;
import org.eclipse.jetty.security.HashLoginService;
/**
* Http Server implementation using Embedded Jetty.
*/
+@ToString
public abstract class JettyServletServer implements HttpServletServer, Runnable {
/**
/**
* Start condition.
*/
+ @ToString.Exclude
protected Object startCondition = new Object();
/**
throw new UnsupportedOperationException("addServletResource()" + NOT_SUPPORTED);
}
- @Override
- public String toString() {
- var builder = new StringBuilder();
- builder.append("JettyServer [name=").append(name).append(", host=").append(host).append(", port=").append(port)
- .append(", user=").append(user).append(", password=").append(password != null).append(", contextPath=")
- .append(contextPath).append(", jettyServer=").append(jettyServer).append(", context=")
- .append(this.context).append(", connector=").append(connector).append(", jettyThread=")
- .append(jettyThread).append("]");
- return builder.toString();
- }
-
}
package org.onap.policy.common.endpoints.report;
+import lombok.ToString;
+
/**
* Class to represent health check report of a service.
*
* @author Ram Krishna Verma (ram.krishna.verma@ericsson.com)
*/
+@ToString
public class HealthCheckReport {
private String name;
public void setMessage(final String message) {
this.message = message;
}
-
- @Override
- public String toString() {
- final var builder = new StringBuilder();
- builder.append("Report [name=");
- builder.append(getName());
- builder.append(", url=");
- builder.append(getUrl());
- builder.append(", healthy=");
- builder.append(isHealthy());
- builder.append(", code=");
- builder.append(getCode());
- builder.append(", message=");
- builder.append(getMessage());
- builder.append("]");
- return builder.toString();
- }
}
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
package org.onap.policy.common.endpoints.http.server.test;
import com.google.gson.annotations.SerializedName;
+import lombok.ToString;
import org.onap.policy.common.gson.annotation.GsonJsonProperty;
/**
* "ECHO" request and response supporting serialization and de-serialization via
* both jackson and gson.
*/
+@ToString
public class RestEchoReqResp {
@GsonJsonProperty("reqId")
@SerializedName("reqId")
public void setText(String text) {
this.text = text;
}
-
- @Override
- public String toString() {
- return "RestEchoReqResp [requestId=" + requestId + ", text=" + text + "]";
- }
}
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019, 2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.Map;
import java.util.TreeMap;
import javax.ws.rs.core.MediaType;
+import lombok.ToString;
import org.junit.Test;
import org.onap.policy.common.endpoints.http.server.YamlJacksonHandler;
import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
/**
* This class includes all policy-specific gson annotations.
*/
+ @ToString
public static class Data {
protected int id;
props.put(name, value);
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + ", value=" + value + ", props=" + props + "]";
- }
}
private static class MyMap {
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.HashMap;
import java.util.Map;
import javax.ws.rs.core.MediaType;
+import lombok.ToString;
import org.junit.Before;
import org.junit.Test;
import org.onap.policy.common.endpoints.http.server.YamlMessageBodyHandler;
}
}
+ @ToString
public static class MyObject {
private int id;
public MyObject(int id) {
this.id = id;
}
-
- @Override
- public String toString() {
- return "MyObject [id=" + id + "]";
- }
}
private static class MyMap {
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
+import lombok.ToString;
import org.apache.commons.jexl3.JexlException;
import org.junit.Before;
import org.junit.Test;
assertEquals("[300,{'objE':true,'objEStr':'obj-e-string'},false]".replace('\'', '"'), jsonEl.toString());
}
+ @ToString
public static class Data {
private int id;
private String text;
public void setText(String text) {
this.text = text;
}
-
- @Override
- public String toString() {
- return "Data [id=" + id + ", text=" + text + "]";
- }
}
}
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
</dependencies>
</project>
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
+import org.apache.commons.io.IOUtils;
/**
* The Class TextFileUtils is class that provides useful functions for handling text files. Functions to read and write
* @author Liam Fallon (liam.fallon@est.tech)
*/
public abstract class TextFileUtils {
- private static final int READER_CHAR_BUFFER_SIZE_4096 = 4096;
private TextFileUtils() {
// This class cannot be initialized
* @throws IOException on errors reading text from the file
*/
public static String getReaderAsString(final Reader textReader) throws IOException {
- final var builder = new StringBuilder();
- int charsRead = -1;
- final var chars = new char[READER_CHAR_BUFFER_SIZE_4096];
- do {
- charsRead = textReader.read(chars);
- if (charsRead > 0) {
- builder.append(chars, 0, charsRead);
- }
- } while (charsRead > 0);
- return builder.toString();
+ return IOUtils.toString(textReader);
}
}
* ============LICENSE_START=======================================================
* ONAP PAP
* ================================================================================
- * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2021 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import lombok.ToString;
import org.junit.Before;
import org.junit.Test;
}
+ @ToString
private static class MyObject {
private String abc;
-
- @Override
- public String toString() {
- return "MyObject [abc=" + abc + "]";
- }
}
public static class MyMap {