Fix checkstyle violations for "final" keyword 64/115964/3
authorClaudio David Gasparini <claudio.gasparini@pantheon.tech>
Tue, 1 Dec 2020 14:28:25 +0000 (15:28 +0100)
committerClaudio David Gasparini <claudio.gasparini@pantheon.tech>
Wed, 2 Dec 2020 07:17:25 +0000 (08:17 +0100)
Issue-ID: CPS-119
Signed-off-by: Claudio David Gasparini <claudio.gasparini@pantheon.tech>
Change-Id: I871a361937ed30047fe89ff2d2b17499cddad56c

13 files changed:
cps-rest/src/main/java/org/onap/cps/Application.java
cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java
cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java
cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java
cps-ri/src/main/java/org/onap/cps/spi/entities/JsonDataEntity.java
cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java
cps-ri/src/main/java/org/onap/cps/spi/repository/DataspaceRepository.java
cps-service/src/main/java/org/onap/cps/api/impl/CpServiceImpl.java
cps-service/src/main/java/org/onap/cps/api/impl/Fragment.java
cps-service/src/main/java/org/onap/cps/exceptions/CpsException.java
cps-service/src/main/java/org/onap/cps/exceptions/CpsNotFoundException.java
cps-service/src/main/java/org/onap/cps/exceptions/CpsValidationException.java
cps-service/src/test/java/org/onap/cps/TestUtils.java

index 9f6c2ed..d8e849d 100644 (file)
@@ -26,7 +26,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
 @SpringBootApplication\r
 public class Application {\r
 \r
-    public static void main(String[] args) {\r
+    public static void main(final String[] args) {\r
         SpringApplication.run(Application.class, args);\r
     }\r
 }
\ No newline at end of file
index 9e57408..549760d 100755 (executable)
@@ -63,7 +63,7 @@ public class CpsRestController implements CpsRestApi {
      * @return a ResponseEntity with the anchor name.
      */
     @Override
-    public final ResponseEntity<String> createAnchor(@Valid Anchor anchor, String dataspaceName) {
+    public final ResponseEntity<String> createAnchor(@Valid final Anchor anchor, final String dataspaceName) {
         final AnchorDetails anchorDetails = modelMapper.map(anchor, AnchorDetails.class);
         anchorDetails.setDataspace(dataspaceName);
         final String anchorName = cpService.createAnchor(anchorDetails);
@@ -71,7 +71,7 @@ public class CpsRestController implements CpsRestApi {
     }
 
     @Override
-    public ResponseEntity<Object> createModules(@Valid MultipartFile multipartFile, String dataspaceName) {
+    public ResponseEntity<Object> createModules(@Valid final MultipartFile multipartFile, final String dataspaceName) {
         final File fileToParse = saveToFile(multipartFile);
         final SchemaContext schemaContext = cpService.parseAndValidateModel(fileToParse);
         cpService.storeSchemaContext(schemaContext, dataspaceName);
@@ -79,42 +79,43 @@ public class CpsRestController implements CpsRestApi {
     }
 
     @Override
-    public ResponseEntity<Object> createNode(@Valid MultipartFile multipartFile, String dataspaceName) {
+    public ResponseEntity<Object> createNode(@Valid final MultipartFile multipartFile, final String dataspaceName) {
         return null;
     }
 
     @Override
-    public ResponseEntity<Object> deleteAnchor(String dataspaceName, String anchorName) {
+    public ResponseEntity<Object> deleteAnchor(final String dataspaceName, final String anchorName) {
         return null;
     }
 
     @Override
-    public ResponseEntity<Object> deleteDataspace(String dataspaceName) {
+    public ResponseEntity<Object> deleteDataspace(final String dataspaceName) {
         return null;
     }
 
     @Override
-    public ResponseEntity<Object> getAnchor(String dataspaceName, String anchorName) {
+    public ResponseEntity<Object> getAnchor(final String dataspaceName, final String anchorName) {
         return null;
     }
 
     @Override
-    public ResponseEntity<Object> getAnchors(String dataspaceName) {
+    public ResponseEntity<Object> getAnchors(final String dataspaceName) {
         return null;
     }
 
     @Override
-    public ResponseEntity<Object> getModule(String dataspaceName, @Valid String namespaceName, @Valid String revision) {
+    public ResponseEntity<Object> getModule(final String dataspaceName, @Valid final String namespaceName,
+            @Valid final String revision) {
         return null;
     }
 
     @Override
-    public ResponseEntity<Object> getNode(String dataspaceName) {
+    public ResponseEntity<Object> getNode(final String dataspaceName) {
         return null;
     }
 
     @Override
-    public ResponseEntity<Object> getNodeByDataspaceAndAnchor(String dataspaceName, String anchorName) {
+    public ResponseEntity<Object> getNodeByDataspaceAndAnchor(final String dataspaceName, final String anchorName) {
         return null;
     }
 
@@ -129,13 +130,11 @@ public class CpsRestController implements CpsRestApi {
      * @return a ResponseEntity.
      */
     @PostMapping("/upload-yang-json-data-file")
-    public final ResponseEntity<String> uploadYangJsonDataFile(
-        @RequestParam("file") MultipartFile uploadedFile) {
+    public final ResponseEntity<String> uploadYangJsonDataFile(@RequestParam("file") final MultipartFile uploadedFile) {
         validateJsonStructure(uploadedFile);
         final int persistenceObjectId = cpService.storeJsonStructure(getJsonString(uploadedFile));
-        return new ResponseEntity<String>(
+        return new ResponseEntity<>(
             "Object stored in CPS with identity: " + persistenceObjectId, HttpStatus.OK);
-
     }
 
     /**
index 2b9ee51..94226b7 100644 (file)
@@ -40,38 +40,39 @@ public class CpsRestExceptionHandler {
      * @return response with response code 500.
      */
     @ExceptionHandler
-    public ResponseEntity<Object> handleInternalErrorException(Exception exception) {
+    public ResponseEntity<Object> handleInternalErrorException(final Exception exception) {
         return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception);
     }
 
     @ExceptionHandler({CpsException.class})
-    public ResponseEntity<Object> handleCpsException(CpsException exception) {
+    public ResponseEntity<Object> handleCpsException(final CpsException exception) {
         return buildErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, exception.getMessage(), extractDetails(exception));
     }
 
     @ExceptionHandler({CpsValidationException.class})
-    public ResponseEntity<Object> handleCpsValidationException(CpsException exception) {
+    public ResponseEntity<Object> handleCpsValidationException(final CpsException exception) {
         return buildErrorResponse(HttpStatus.BAD_REQUEST, exception.getMessage(), extractDetails(exception));
     }
 
     @ExceptionHandler({CpsNotFoundException.class})
-    public ResponseEntity<Object> handleCpsNotFoundException(CpsException exception) {
+    public ResponseEntity<Object> handleCpsNotFoundException(final CpsException exception) {
         return buildErrorResponse(HttpStatus.NOT_FOUND, exception.getMessage(), extractDetails(exception));
     }
 
-    private static ResponseEntity<Object> buildErrorResponse(HttpStatus status, Exception exception) {
+    private static ResponseEntity<Object> buildErrorResponse(final HttpStatus status, final Exception exception) {
         return buildErrorResponse(status, exception.getMessage(), ExceptionUtils.getStackTrace(exception));
     }
 
-    private static ResponseEntity<Object> buildErrorResponse(HttpStatus status, String message, String details) {
-        ErrorMessage errorMessage = new ErrorMessage();
+    private static ResponseEntity<Object> buildErrorResponse(final HttpStatus status, final String message,
+            final String details) {
+        final ErrorMessage errorMessage = new ErrorMessage();
         errorMessage.setStatus(status.toString());
         errorMessage.setMessage(message);
         errorMessage.setDetails(details);
         return new ResponseEntity<>(errorMessage, status);
     }
 
-    private static String extractDetails(CpsException exception) {
+    private static String extractDetails(final CpsException exception) {
         return exception.getCause() == null
             ? exception.getDetails()
             : ExceptionUtils.getStackTrace(exception.getCause());
index aeab4f8..9f127f4 100644 (file)
@@ -59,7 +59,7 @@ public class Dataspace implements Serializable {
      *
      * @param name the Dataspace name.
      */
-    public Dataspace(String name) {
+    public Dataspace(final String name) {
         this.name = name;
     }
 }
\ No newline at end of file
index 413362e..bd147bf 100644 (file)
@@ -48,7 +48,7 @@ public class JsonDataEntity {
     @Column
     private String jsonStructure;
 
-    public JsonDataEntity(String jsonStructure) {
+    public JsonDataEntity(final String jsonStructure) {
         this.jsonStructure = jsonStructure;
     }
 }
index ef6895c..7043c73 100755 (executable)
@@ -36,7 +36,6 @@ import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
 
-
 /**
  * Entity to store a yang module.
  */
@@ -73,12 +72,13 @@ public class Module implements Serializable {
     /**
      * Initialize a module entity.
      *
-     * @param namespace the module namespace.
+     * @param namespace     the module namespace.
      * @param moduleContent the module content.
-     * @param revision the revision number of the module.
-     * @param dataspace the dataspace related to the module.
+     * @param revision      the revision number of the module.
+     * @param dataspace     the dataspace related to the module.
      */
-    public Module(String namespace, String moduleContent, String revision, Dataspace dataspace) {
+    public Module(final String namespace, final String moduleContent, final String revision,
+            final Dataspace dataspace) {
         this.namespace = namespace;
         this.moduleContent = moduleContent;
         this.revision = revision;
index ad8004c..daf0b71 100755 (executable)
@@ -19,7 +19,6 @@
 
 package org.onap.cps.spi.repository;
 
-
 import java.util.Optional;
 import javax.validation.constraints.NotNull;
 import org.onap.cps.exceptions.CpsNotFoundException;
index 93ed8b8..3daf9a0 100755 (executable)
@@ -88,7 +88,7 @@ public class CpServiceImpl implements CpService {
     }
 
     @Override
-    public void deleteJsonById(int jsonObjectId) {
+    public void deleteJsonById(final int jsonObjectId) {
         dataPersistenceService.deleteJsonById(jsonObjectId);
     }
 
@@ -103,7 +103,7 @@ public class CpServiceImpl implements CpService {
     }
 
     @Override
-    public String createAnchor(AnchorDetails anchorDetails) {
+    public String createAnchor(final AnchorDetails anchorDetails) {
         return fragmentPersistenceService.createAnchor(anchorDetails);
     }
 }
\ No newline at end of file
index 90c92f9..0f785b7 100644 (file)
@@ -76,7 +76,7 @@ public class Fragment {
      * @param qnames         array of qualified names that points the schema node for this fragment
      * @param xpath          the xpath for this fragment
      */
-    private Fragment(final Fragment parentFragment, final Module module, final QName[] qnames, String xpath) {
+    private Fragment(final Fragment parentFragment, final Module module, final QName[] qnames, final String xpath) {
         this.parentFragment = parentFragment;
         this.module = module;
         this.qnames = qnames;
index 4dd19dd..acdada1 100644 (file)
@@ -36,7 +36,7 @@ public class CpsException extends RuntimeException {
      *
      * @param cause the cause of the exception
      */
-    public CpsException(Throwable cause) {
+    public CpsException(final Throwable cause) {
         super(cause.getMessage(), cause);
     }
 
@@ -46,7 +46,7 @@ public class CpsException extends RuntimeException {
      * @param message the error message
      * @param cause   the cause of the exception
      */
-    public CpsException(String message, Throwable cause) {
+    public CpsException(final  String message, final Throwable cause) {
         super(message, cause);
     }
 
@@ -56,7 +56,7 @@ public class CpsException extends RuntimeException {
      * @param message the error message
      * @param details the error details
      */
-    public CpsException(String message, String details) {
+    public CpsException(final String message, final String details) {
         super(message);
         this.details = details;
     }
index 4613da8..e66c3bd 100644 (file)
@@ -32,7 +32,7 @@ public class CpsNotFoundException extends CpsException {
      *
      * @param cause the cause of the exception
      */
-    public CpsNotFoundException(Throwable cause) {
+    public CpsNotFoundException(final Throwable cause) {
         super(cause.getMessage(), cause);
     }
 
@@ -42,7 +42,7 @@ public class CpsNotFoundException extends CpsException {
      * @param message the error message
      * @param cause   the cause of the exception
      */
-    public CpsNotFoundException(String message, Throwable cause) {
+    public CpsNotFoundException(final String message, final Throwable cause) {
         super(message, cause);
     }
 
@@ -52,7 +52,7 @@ public class CpsNotFoundException extends CpsException {
      * @param message the error message
      * @param details the error details
      */
-    public CpsNotFoundException(String message, String details) {
+    public CpsNotFoundException(final String message, final String details) {
         super(message, details);
     }
 }
index dba9c16..8e049c6 100644 (file)
@@ -29,7 +29,7 @@ public class CpsValidationException extends CpsException {
      *
      * @param cause the cause of the exception
      */
-    public CpsValidationException(Throwable cause) {
+    public CpsValidationException(final Throwable cause) {
         super(cause.getMessage(), cause);
     }
 
@@ -39,7 +39,7 @@ public class CpsValidationException extends CpsException {
      * @param message the error message
      * @param cause   the cause of the exception
      */
-    public CpsValidationException(String message, Throwable cause) {
+    public CpsValidationException(final String message, final Throwable cause) {
         super(message, cause);
     }
 
@@ -49,7 +49,7 @@ public class CpsValidationException extends CpsException {
      * @param message the error message
      * @param details the error details
      */
-    public CpsValidationException(String message, String details) {
+    public CpsValidationException(final String message, final String details) {
         super(message, details);
     }
 }
index 0764752..3a2a4e3 100644 (file)
@@ -35,7 +35,7 @@ public class TestUtils {
      * @throws IOException when there is an IO issue
      */
     public static String getResourceFileContent(final String filename) throws IOException {
-        File file = new File(ClassLoader.getSystemClassLoader().getResource(filename).getFile());
+        final File file = new File(ClassLoader.getSystemClassLoader().getResource(filename).getFile());
         return new String(Files.readAllBytes(file.toPath()));
     }
 }