Make the deserializers final. Reduce their visibility at package level.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@162830 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
85bacd7afe
commit
3f71638206
|
@ -1,12 +1,9 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.resourcemanagement.manager.io.codeexceptions.deserializer;
|
||||
|
||||
import org.gcube.resourcemanagement.manager.io.codeexceptions.ErrorCode;
|
||||
|
||||
/**
|
||||
* Don't forget to comment!
|
||||
* Deserializer for {@link ErrorCode}.
|
||||
*
|
||||
* @author Manuele Simi (ISTI CNR)
|
||||
*
|
||||
|
@ -22,7 +19,7 @@ final class ErrorCodeDeserializer {
|
|||
* The error code, if any
|
||||
* @return the error code or null
|
||||
*/
|
||||
public static ErrorCode deserialize(int id, String message) {
|
||||
protected static ErrorCode deserialize(int id, String message) {
|
||||
if (id != 1) {
|
||||
return new ErrorCode() {
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.gcube.resourcemanagement.manager.io.codeexceptions.ErrorCode;
|
|||
import org.gcube.resourcemanagement.manager.io.codeexceptions.SerializableErrorEntity;
|
||||
|
||||
/**
|
||||
* Don't forget to comment!
|
||||
* Manager for extracting information held inside a {@link SerializableErrorEntity}.
|
||||
*
|
||||
* @author Manuele Simi (ISTI CNR)
|
||||
*
|
||||
|
@ -21,18 +21,34 @@ public class ErrorEntityManager {
|
|||
this.entity = entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is an {@link Exception} in the entity.
|
||||
* @return true if the entity holds an exception, false otherwise
|
||||
*/
|
||||
public boolean hasException() {
|
||||
return Objects.nonNull(this.entity.getExceptionClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Exception} inside the entity.
|
||||
* @return the exception or null
|
||||
*/
|
||||
public <E extends Exception> E getException() {
|
||||
return ExceptionDeserializer.deserialize(this.entity.getExceptionClass(),this.entity.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there is an {@link ErrorCode} in the entity.
|
||||
* @return true if the entity holds an errorcode, false otherwise
|
||||
*/
|
||||
public boolean hasErrorCode() {
|
||||
return this.entity.getId() != -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link ErrorCode} inside the entity.
|
||||
* @return the error code or null
|
||||
*/
|
||||
public ErrorCode getErrorCode(){
|
||||
return ErrorCodeDeserializer.deserialize(this.entity.getId(), this.entity.getMessage());
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.lang.reflect.InvocationTargetException;
|
|||
* @author Manuele Simi (ISTI CNR)
|
||||
*
|
||||
*/
|
||||
class ExceptionDeserializer {
|
||||
final class ExceptionDeserializer {
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -17,7 +17,7 @@ class ExceptionDeserializer {
|
|||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E extends Exception> E deserialize(String exceptionClass, String message) {
|
||||
protected static <E extends Exception> E deserialize(String exceptionClass, String message) {
|
||||
try {
|
||||
final Class<?>[] ctorParams = {String.class};
|
||||
return (E) Class.forName(exceptionClass).getConstructor(ctorParams).newInstance(message);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
/**
|
||||
* Don't forget to comment!
|
||||
* Helper classes to deserialize the information held inside a {@link org.gcube.resourcemanagement.manager.io.codeexceptions.SerializableErrorEntity}.
|
||||
*
|
||||
* @author Manuele Simi (ISTI CNR)
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue