diff options
author | Claudio David Gasparini <claudio.gasparini@pantheon.tech> | 2020-12-01 15:28:25 +0100 |
---|---|---|
committer | Claudio David Gasparini <claudio.gasparini@pantheon.tech> | 2020-12-02 08:17:25 +0100 |
commit | b1740000e774ca633309e640f190cdcd74aa8241 (patch) | |
tree | a9d5a861b4f056c661d3742a534a9635838aa064 | |
parent | c8f2136670321731ec97d027d427af2ec9fd1077 (diff) |
Fix checkstyle violations for "final" keyword
Issue-ID: CPS-119
Signed-off-by: Claudio David Gasparini <claudio.gasparini@pantheon.tech>
Change-Id: I871a361937ed30047fe89ff2d2b17499cddad56c
13 files changed, 43 insertions, 44 deletions
diff --git a/cps-rest/src/main/java/org/onap/cps/Application.java b/cps-rest/src/main/java/org/onap/cps/Application.java index 9f6c2edce9..d8e849d53d 100644 --- a/cps-rest/src/main/java/org/onap/cps/Application.java +++ b/cps-rest/src/main/java/org/onap/cps/Application.java @@ -26,7 +26,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication
public class Application {
- public static void main(String[] args) {
+ public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
}
\ No newline at end of file diff --git a/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java b/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java index 9e57408fb7..549760d2f8 100755 --- a/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/controller/CpsRestController.java @@ -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); - } /** diff --git a/cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java b/cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java index 2b9ee51fa6..94226b78c0 100644 --- a/cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java +++ b/cps-rest/src/main/java/org/onap/cps/rest/exceptions/CpsRestExceptionHandler.java @@ -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()); diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java index aeab4f844b..9f127f432a 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/Dataspace.java @@ -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 diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/JsonDataEntity.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/JsonDataEntity.java index 413362e384..bd147bf73c 100644 --- a/cps-ri/src/main/java/org/onap/cps/spi/entities/JsonDataEntity.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/JsonDataEntity.java @@ -48,7 +48,7 @@ public class JsonDataEntity { @Column private String jsonStructure; - public JsonDataEntity(String jsonStructure) { + public JsonDataEntity(final String jsonStructure) { this.jsonStructure = jsonStructure; } } diff --git a/cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java b/cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java index ef6895c7d4..7043c73952 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/entities/Module.java @@ -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; diff --git a/cps-ri/src/main/java/org/onap/cps/spi/repository/DataspaceRepository.java b/cps-ri/src/main/java/org/onap/cps/spi/repository/DataspaceRepository.java index ad8004c07d..daf0b716b7 100755 --- a/cps-ri/src/main/java/org/onap/cps/spi/repository/DataspaceRepository.java +++ b/cps-ri/src/main/java/org/onap/cps/spi/repository/DataspaceRepository.java @@ -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; diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/CpServiceImpl.java b/cps-service/src/main/java/org/onap/cps/api/impl/CpServiceImpl.java index 93ed8b8468..3daf9a0d69 100755 --- a/cps-service/src/main/java/org/onap/cps/api/impl/CpServiceImpl.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/CpServiceImpl.java @@ -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 diff --git a/cps-service/src/main/java/org/onap/cps/api/impl/Fragment.java b/cps-service/src/main/java/org/onap/cps/api/impl/Fragment.java index 90c92f905e..0f785b718f 100644 --- a/cps-service/src/main/java/org/onap/cps/api/impl/Fragment.java +++ b/cps-service/src/main/java/org/onap/cps/api/impl/Fragment.java @@ -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; diff --git a/cps-service/src/main/java/org/onap/cps/exceptions/CpsException.java b/cps-service/src/main/java/org/onap/cps/exceptions/CpsException.java index 4dd19dd82b..acdada14ae 100644 --- a/cps-service/src/main/java/org/onap/cps/exceptions/CpsException.java +++ b/cps-service/src/main/java/org/onap/cps/exceptions/CpsException.java @@ -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; } diff --git a/cps-service/src/main/java/org/onap/cps/exceptions/CpsNotFoundException.java b/cps-service/src/main/java/org/onap/cps/exceptions/CpsNotFoundException.java index 4613da8f23..e66c3bd3b9 100644 --- a/cps-service/src/main/java/org/onap/cps/exceptions/CpsNotFoundException.java +++ b/cps-service/src/main/java/org/onap/cps/exceptions/CpsNotFoundException.java @@ -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); } } diff --git a/cps-service/src/main/java/org/onap/cps/exceptions/CpsValidationException.java b/cps-service/src/main/java/org/onap/cps/exceptions/CpsValidationException.java index dba9c165b8..8e049c66e4 100644 --- a/cps-service/src/main/java/org/onap/cps/exceptions/CpsValidationException.java +++ b/cps-service/src/main/java/org/onap/cps/exceptions/CpsValidationException.java @@ -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); } } diff --git a/cps-service/src/test/java/org/onap/cps/TestUtils.java b/cps-service/src/test/java/org/onap/cps/TestUtils.java index 07647520b0..3a2a4e3a55 100644 --- a/cps-service/src/test/java/org/onap/cps/TestUtils.java +++ b/cps-service/src/test/java/org/onap/cps/TestUtils.java @@ -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())); } } |