Changed the property value type from Serializable to Comparable<? extends Serializable> which is much more what represent the value of a property. This should not imply any changes in clients.

All tests run. All tests OK.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-lib@120485 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-11-30 16:49:18 +00:00
parent 1987001f31
commit 523bb8c8bd
38 changed files with 72 additions and 72 deletions

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.accounting</groupId>
<artifactId>accounting-lib</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.1.1-SNAPSHOT</version>
<name>Accounting Library</name>
<description>Accounting Library</description>
<packaging>jar</packaging>

View File

@ -31,7 +31,7 @@ public class AggregatedJobUsageRecord extends AbstractJobUsageRecord implements
init();
}
public AggregatedJobUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
public AggregatedJobUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
super(properties);
init();
}

View File

@ -32,7 +32,7 @@ public class AggregatedPortletUsageRecord extends AbstractPortletUsageRecord imp
init();
}
public AggregatedPortletUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
public AggregatedPortletUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
super(properties);
init();
}

View File

@ -44,7 +44,7 @@ public class AggregatedServiceUsageRecord extends AbstractServiceUsageRecord imp
init();
}
public AggregatedServiceUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
public AggregatedServiceUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
super(properties);
init();
}

View File

@ -39,7 +39,7 @@ public class AggregatedStorageUsageRecord extends AbstractStorageUsageRecord imp
init();
}
public AggregatedStorageUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
public AggregatedStorageUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
super(properties);
init();
}

View File

@ -32,7 +32,7 @@ public class AggregatedTaskUsageRecord extends AbstractTaskUsageRecord implement
init();
}
public AggregatedTaskUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
public AggregatedTaskUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
super(properties);
init();
}

View File

@ -70,8 +70,8 @@ public abstract class AggregationStrategy<T extends AggregatedUsageRecord<T, B>,
protected boolean isAggregable(UsageRecord record) {
for(String field : aggregationField){
Serializable recordValue = record.getResourceProperty(field);
Serializable thisValue = ((BasicUsageRecord) t).getResourceProperty(field);
Comparable<? extends Serializable> recordValue = record.getResourceProperty(field);
Comparable<? extends Serializable> thisValue = ((BasicUsageRecord) t).getResourceProperty(field);
if(!recordValue.equals(thisValue)){
return false;

View File

@ -89,7 +89,7 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
/** resource-specific properties */
protected Map<String, Serializable> resourceProperties;
protected Map<String, Comparable<? extends Serializable>> resourceProperties;
protected Map<String, List<FieldAction>> validation;
protected Set<String> requiredFields;
@ -194,7 +194,7 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
this.requiredFields = new HashSet<String>();
this.aggregatedFields = new HashSet<String>();
this.computedFields = new HashSet<String>();
this.resourceProperties = new HashMap<String, Serializable>();
this.resourceProperties = new HashMap<String, Comparable<? extends Serializable>>();
initializeValidation();
try {
this.setScope(ScopeProvider.instance.get());
@ -211,7 +211,7 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
this.resourceProperties.put(CREATION_TIME, calendar.getTimeInMillis());
}
public BasicUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
public BasicUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
init();
setResourceProperties(properties);
}
@ -305,24 +305,24 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
* {@inheritDoc}
*/
@Override
public Map<String, Serializable> getResourceProperties() {
return new HashMap<String, Serializable>(this.resourceProperties);
public Map<String, Comparable<? extends Serializable>> getResourceProperties() {
return new HashMap<String, Comparable<? extends Serializable>>(this.resourceProperties);
}
/**
* {@inheritDoc}
*/
@Override
public void setResourceProperties(Map<String, Serializable> properties) throws InvalidValueException {
Map<String, Serializable> validated = validateProperties(properties);
this.resourceProperties = new HashMap<String, Serializable>(validated);
public void setResourceProperties(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
Map<String, Comparable<? extends Serializable>> validated = validateProperties(properties);
this.resourceProperties = new HashMap<String, Comparable<? extends Serializable>>(validated);
}
/**
* {@inheritDoc}
*/
@Override
public Serializable getResourceProperty(String key) {
public Comparable<? extends Serializable> getResourceProperty(String key) {
return this.resourceProperties.get(key);
}
@ -330,8 +330,8 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
* {@inheritDoc}
*/
@Override
public void setResourceProperty(String key, Serializable value) throws InvalidValueException {
Serializable checkedValue = validateField(key, value);
public void setResourceProperty(String key, Comparable<? extends Serializable> value) throws InvalidValueException {
Comparable<? extends Serializable> checkedValue = validateField(key, value);
if(checkedValue == null){
this.resourceProperties.remove(key);
}else{
@ -405,11 +405,11 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
protected Serializable validateField(String key, Serializable serializable) throws InvalidValueException {
protected Comparable<? extends Serializable> validateField(String key, Comparable<? extends Serializable> value) throws InvalidValueException {
if(key == null){
throw new InvalidValueException("The key of property to set cannot be null");
}
Serializable checkedValue = serializable;
Comparable<? extends Serializable> checkedValue = value;
List<FieldAction> fieldValidators = validation.get(key);
if(fieldValidators!=null){
for(FieldAction fieldValidator : fieldValidators){
@ -430,11 +430,11 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
return checkedValue;
}
protected Map<String, Serializable> validateProperties(Map<String, Serializable> properties) throws InvalidValueException{
Map<String, Serializable> validated = new HashMap<String, Serializable>();
protected Map<String, Comparable<? extends Serializable>> validateProperties(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
Map<String, Comparable<? extends Serializable>> validated = new HashMap<String, Comparable<? extends Serializable>>();
for(String key : properties.keySet()){
Serializable serializable = properties.get(key);
validated.put(key, validateField(key, serializable));
Comparable<? extends Serializable> value = properties.get(key);
validated.put(key, validateField(key, value));
}
return validated;
}
@ -493,8 +493,8 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
*/
@Override
public int compareTo(UsageRecord usageRecord) {
Set<Entry<String, Serializable>> thisSet = this.resourceProperties.entrySet();
Set<Entry<String, Serializable>> usageRecordSet = usageRecord.getResourceProperties().entrySet();
Set<Entry<String, Comparable<? extends Serializable>>> thisSet = this.resourceProperties.entrySet();
Set<Entry<String, Comparable<? extends Serializable>>> usageRecordSet = usageRecord.getResourceProperties().entrySet();
if(thisSet.size() != usageRecordSet.size()){
return thisSet.size() - usageRecordSet.size();
}
@ -537,7 +537,7 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
* @return the instance of the UsageRecord class.
* @throws Exception if fails
*/
public static UsageRecord getUsageRecord(Map<String, Serializable> usageRecordMap) throws Exception {
public static UsageRecord getUsageRecord(Map<String, Comparable<? extends Serializable>> usageRecordMap) throws Exception {
String className = (String) usageRecordMap.get(USAGE_RECORD_TYPE);
boolean aggregated = false;
try {
@ -579,7 +579,7 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
private final static String KEY_VALUE_PAIR_SEPARATOR = ",";
private final static String KEY_VALUE_LINKER = "=";
protected static Map<String, Serializable> getMapFromString(String serializedMap){
protected static Map<String, Comparable<? extends Serializable>> getMapFromString(String serializedMap){
/* Checking line sanity */
if(!serializedMap.startsWith(LINE_FREFIX) && !serializedMap.endsWith(LINE_SUFFIX)){
return null;
@ -589,7 +589,7 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
serializedMap = serializedMap.replace(LINE_FREFIX, "");
serializedMap = serializedMap.replace(LINE_SUFFIX, "");
Map<String, Serializable> map = new HashMap<String, Serializable>();
Map<String, Comparable<? extends Serializable>> map = new HashMap<String, Comparable<? extends Serializable>>();
String[] pairs = serializedMap.split(KEY_VALUE_PAIR_SEPARATOR);
for (int i=0;i<pairs.length;i++) {
@ -598,7 +598,7 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
String[] keyValue = pair.split(KEY_VALUE_LINKER);
String key = keyValue[0].trim();
Serializable value = keyValue[1].trim();
Comparable<? extends Serializable> value = keyValue[1].trim();
map.put(key, value);
}
@ -613,7 +613,7 @@ public abstract class BasicUsageRecord implements UsageRecord, Serializable {
* @throws Exception
*/
public static UsageRecord getUsageRecord(String serializedMap) throws Exception {
Map<String,Serializable> map = getMapFromString(serializedMap);
Map<String,Comparable<? extends Serializable>> map = getMapFromString(serializedMap);
return getUsageRecord(map);
}
}

View File

@ -105,7 +105,7 @@ public class RawUsageRecord extends BasicUsageRecord implements SingleUsageRecor
}
@Deprecated
public RawUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
public RawUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
super(properties);
}
@ -320,7 +320,7 @@ public class RawUsageRecord extends BasicUsageRecord implements SingleUsageRecor
*/
@Deprecated
public void setResourceSpecificProperties(Map<String, String> properties) throws InvalidValueException {
Map<String, Serializable> map = new HashMap<String, Serializable>(properties);
Map<String, Comparable<? extends Serializable>> map = new HashMap<String, Comparable<? extends Serializable>>(properties);
setResourceProperties(map);
}
@ -342,7 +342,7 @@ public class RawUsageRecord extends BasicUsageRecord implements SingleUsageRecor
* @param value the value of the given resource property
*/
@Deprecated
public void setResourceSpecificProperty(String key, Serializable value) {
public void setResourceSpecificProperty(String key, Comparable<? extends Serializable> value) {
try {
setResourceProperty(key, value);
} catch (InvalidValueException e) {

View File

@ -89,19 +89,19 @@ public interface UsageRecord extends Comparable<UsageRecord> {
* not affect the object
* @return a Map containing the properties
*/
public Map<String, Serializable> getResourceProperties();
public Map<String, Comparable<? extends Serializable>> getResourceProperties();
/**
* Set all resource-specific properties, replacing existing ones
*/
public void setResourceProperties(Map<String, Serializable> resourceSpecificProperties) throws InvalidValueException;
public void setResourceProperties(Map<String, Comparable<? extends Serializable>> resourceSpecificProperties) throws InvalidValueException;
/**
* Return the value of the given resource property.
* @param key the key of the requested property
* @return the value of the given resource property
*/
public Serializable getResourceProperty(String key);
public Comparable<? extends Serializable> getResourceProperty(String key);
/**
* Set the value of the given resource property.
@ -110,7 +110,7 @@ public interface UsageRecord extends Comparable<UsageRecord> {
* @param key the key of the requested property
* @param value the value of the given resource property
*/
public void setResourceProperty(String key, Serializable value) throws InvalidValueException;
public void setResourceProperty(String key, Comparable<? extends Serializable> value) throws InvalidValueException;
/**
* @return the Operation Result of the accounted operation.

View File

@ -13,7 +13,7 @@ import org.gcube.accounting.exception.InvalidValueException;
public class MoveToCreationTimeAction implements FieldAction {
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
if(value instanceof Date){
Calendar calendar = Calendar.getInstance();
calendar.setTime((Date) value);

View File

@ -11,7 +11,7 @@ import org.gcube.accounting.exception.InvalidValueException;
public class MoveToScopeAction implements FieldAction {
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
if(value instanceof String){
usageRecord.setScope((String) value);
}else{

View File

@ -14,7 +14,7 @@ import org.gcube.accounting.exception.InvalidValueException;
public class MoveToUsageRecordTypeAction implements FieldAction {
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
if(value instanceof String){
String newValue = RawUsageRecord.resourceTypeMapping.get(value);
if(newValue == null){

View File

@ -55,7 +55,7 @@ public abstract class AbstractJobUsageRecord extends BasicUsageRecord {
super();
}
public AbstractJobUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
public AbstractJobUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
super(properties);
}

View File

@ -40,7 +40,7 @@ public abstract class AbstractPortletUsageRecord extends BasicUsageRecord {
protected @interface MoveToConsumerId { }
protected class MoveToConsumerIdAction implements FieldAction {
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
NotEmptyIfNotNullValidator neinnv = new NotEmptyIfNotNullValidator();
value = neinnv.validate(key, value, usageRecord);
usageRecord.setConsumerId((String) value);
@ -59,7 +59,7 @@ public abstract class AbstractPortletUsageRecord extends BasicUsageRecord {
super();
}
public AbstractPortletUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
public AbstractPortletUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
super(properties);
}

View File

@ -63,7 +63,7 @@ public abstract class AbstractServiceUsageRecord extends BasicUsageRecord {
super();
}
public AbstractServiceUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
public AbstractServiceUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
super(properties);
}

View File

@ -107,7 +107,7 @@ public abstract class AbstractStorageUsageRecord extends BasicUsageRecord {
super();
}
public AbstractStorageUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
public AbstractStorageUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
super(properties);
}

View File

@ -70,7 +70,7 @@ public abstract class AbstractTaskUsageRecord extends BasicUsageRecord {
super();
}
public AbstractTaskUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
public AbstractTaskUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
super(properties);
}

View File

@ -16,7 +16,7 @@ public class CalculateWallDurationAction implements FieldAction {
private static final Logger logger = LoggerFactory.getLogger(CalculateWallDurationAction.class);
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
try {
long wallDuration = ((AbstractJobUsageRecord) usageRecord).calculateWallDuration();
if(key.compareTo(AbstractJobUsageRecord.WALL_DURATION)==0){

View File

@ -24,6 +24,6 @@ public interface FieldAction {
* @throws InvalidValueException if the validation or the eventual
* conversion fails
*/
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException;
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException;
}

View File

@ -23,7 +23,7 @@ public class DeprecatedWarningAction implements FieldAction {
* {@inheritDoc}
*/
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
logger.trace("The field {} is deprecated for {}. Anyway the field will be included in the document",
key, usageRecord.getClass().getSimpleName());
return value;

View File

@ -21,7 +21,7 @@ public class MoveToOperationResultAction implements FieldAction {
* {@inheritDoc}
*/
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
ValidOperationResultValidator vorv = new ValidOperationResultValidator();
value = vorv.validate(key, value, usageRecord);
usageRecord.setOperationResult((OperationResult) value);

View File

@ -18,7 +18,7 @@ public class JobUsageRecord extends AbstractJobUsageRecord implements SingleUsag
super();
}
public JobUsageRecord(Map<String, Serializable> properties) throws InvalidValueException{
public JobUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException{
super(properties);
}
}

View File

@ -18,7 +18,7 @@ public class PortletUsageRecord extends AbstractPortletUsageRecord implements Si
super();
}
public PortletUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
public PortletUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
super(properties);
}

View File

@ -18,7 +18,7 @@ public class ServiceUsageRecord extends AbstractServiceUsageRecord implements Si
super();
}
public ServiceUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
public ServiceUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
super(properties);
}
}

View File

@ -18,7 +18,7 @@ public class StorageUsageRecord extends AbstractStorageUsageRecord implements Si
super();
}
public StorageUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
public StorageUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
super(properties);
}

View File

@ -18,7 +18,7 @@ public class TaskUsageRecord extends AbstractTaskUsageRecord implements SingleUs
super();
}
public TaskUsageRecord(Map<String, Serializable> properties) throws InvalidValueException {
public TaskUsageRecord(Map<String, Comparable<? extends Serializable>> properties) throws InvalidValueException {
super(properties);
}
}

View File

@ -46,7 +46,7 @@ public class FixDataVolumeSignAction implements FieldAction {
* {@inheritDoc}
*/
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
try {
if(key.compareTo(AbstractStorageUsageRecord.DATA_VOLUME)==0){

View File

@ -28,9 +28,9 @@ public class NotEmptyValidator implements FieldAction{
* {@inheritDoc}
*/
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
try{
if(isValid(value)){
if(isValid((Serializable) value)){
return value;
}
}catch(Exception e){

View File

@ -14,7 +14,7 @@ public class NotNullValidator implements FieldAction {
* {@inheritDoc}
*/
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
if(value!=null){
return value;
}

View File

@ -16,7 +16,7 @@ public class ValidDataTypeValidator implements FieldAction {
*/
@SuppressWarnings("rawtypes")
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
if(value instanceof DataType){
return value;
}

View File

@ -47,7 +47,7 @@ public class ValidIPValidator implements FieldAction{
* {@inheritDoc}
*/
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
try {
if(isIpAddress((String) value)){
return (String) value;

View File

@ -15,7 +15,7 @@ public class ValidIntegerValidator implements FieldAction {
* {@inheritDoc}
*/
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
if(value instanceof Integer){
return value;
}

View File

@ -15,7 +15,7 @@ public class ValidLongValidator implements FieldAction {
* {@inheritDoc}
*/
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
if(value instanceof Long){
return value;
}

View File

@ -16,7 +16,7 @@ public class ValidOperationResultValidator implements FieldAction {
*/
@SuppressWarnings("rawtypes")
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
if(value instanceof OperationResult){
return value;
}

View File

@ -17,7 +17,7 @@ public class ValidOperationTypeValidator implements FieldAction {
*/
@SuppressWarnings("rawtypes")
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
if(value instanceof OperationType){
return value;
}

View File

@ -15,7 +15,7 @@ public class ValidURIValidator implements FieldAction {
* {@inheritDoc}
*/
@Override
public Serializable validate(String key, Serializable value, UsageRecord usageRecord) throws InvalidValueException {
public Comparable<? extends Serializable> validate(String key, Comparable<? extends Serializable> value, UsageRecord usageRecord) throws InvalidValueException {
try {
if(value instanceof URI){
return value;

View File

@ -18,13 +18,13 @@ public class NotEmptyIfNotNullValidatorTest {
@Test
public void testBoolean() throws InvalidValueException{
NotEmptyIfNotNullValidator notEmptyIfNotNullValidator = new NotEmptyIfNotNullValidator();
Serializable primitiveTrue = notEmptyIfNotNullValidator.validate(null, true, null);
Comparable<? extends Serializable> primitiveTrue = notEmptyIfNotNullValidator.validate(null, true, null);
Assert.assertTrue((Boolean) primitiveTrue);
Serializable primitiveFalse = notEmptyIfNotNullValidator.validate(null, false, null);
Comparable<? extends Serializable> primitiveFalse = notEmptyIfNotNullValidator.validate(null, false, null);
Assert.assertFalse((Boolean) primitiveFalse);
Serializable booleanClassTrue = notEmptyIfNotNullValidator.validate(null, Boolean.TRUE, null);
Comparable<? extends Serializable> booleanClassTrue = notEmptyIfNotNullValidator.validate(null, Boolean.TRUE, null);
Assert.assertTrue((Boolean) booleanClassTrue);
Serializable booleanClassFalse = notEmptyIfNotNullValidator.validate(null, Boolean.FALSE, null);
Comparable<? extends Serializable> booleanClassFalse = notEmptyIfNotNullValidator.validate(null, Boolean.FALSE, null);
Assert.assertFalse((Boolean) booleanClassFalse);
}
}