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> <groupId>org.gcube.accounting</groupId>
<artifactId>accounting-lib</artifactId> <artifactId>accounting-lib</artifactId>
<version>1.1.0-SNAPSHOT</version> <version>1.1.1-SNAPSHOT</version>
<name>Accounting Library</name> <name>Accounting Library</name>
<description>Accounting Library</description> <description>Accounting Library</description>
<packaging>jar</packaging> <packaging>jar</packaging>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -89,19 +89,19 @@ public interface UsageRecord extends Comparable<UsageRecord> {
* not affect the object * not affect the object
* @return a Map containing the properties * @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 * 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. * Return the value of the given resource property.
* @param key the key of the requested property * @param key the key of the requested property
* @return the value of the given resource 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. * 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 key the key of the requested property
* @param value the value of the given resource 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. * @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 { public class MoveToCreationTimeAction implements FieldAction {
@Override @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){ if(value instanceof Date){
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime((Date) value); calendar.setTime((Date) value);

View File

@ -11,7 +11,7 @@ import org.gcube.accounting.exception.InvalidValueException;
public class MoveToScopeAction implements FieldAction { public class MoveToScopeAction implements FieldAction {
@Override @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){ if(value instanceof String){
usageRecord.setScope((String) value); usageRecord.setScope((String) value);
}else{ }else{

View File

@ -14,7 +14,7 @@ import org.gcube.accounting.exception.InvalidValueException;
public class MoveToUsageRecordTypeAction implements FieldAction { public class MoveToUsageRecordTypeAction implements FieldAction {
@Override @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){ if(value instanceof String){
String newValue = RawUsageRecord.resourceTypeMapping.get(value); String newValue = RawUsageRecord.resourceTypeMapping.get(value);
if(newValue == null){ if(newValue == null){

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,7 @@ public class CalculateWallDurationAction implements FieldAction {
private static final Logger logger = LoggerFactory.getLogger(CalculateWallDurationAction.class); private static final Logger logger = LoggerFactory.getLogger(CalculateWallDurationAction.class);
@Override @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 { try {
long wallDuration = ((AbstractJobUsageRecord) usageRecord).calculateWallDuration(); long wallDuration = ((AbstractJobUsageRecord) usageRecord).calculateWallDuration();
if(key.compareTo(AbstractJobUsageRecord.WALL_DURATION)==0){ if(key.compareTo(AbstractJobUsageRecord.WALL_DURATION)==0){

View File

@ -24,6 +24,6 @@ public interface FieldAction {
* @throws InvalidValueException if the validation or the eventual * @throws InvalidValueException if the validation or the eventual
* conversion fails * 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} * {@inheritDoc}
*/ */
@Override @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", logger.trace("The field {} is deprecated for {}. Anyway the field will be included in the document",
key, usageRecord.getClass().getSimpleName()); key, usageRecord.getClass().getSimpleName());
return value; return value;

View File

@ -21,7 +21,7 @@ public class MoveToOperationResultAction implements FieldAction {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @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(); ValidOperationResultValidator vorv = new ValidOperationResultValidator();
value = vorv.validate(key, value, usageRecord); value = vorv.validate(key, value, usageRecord);
usageRecord.setOperationResult((OperationResult) value); usageRecord.setOperationResult((OperationResult) value);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -46,7 +46,7 @@ public class FixDataVolumeSignAction implements FieldAction {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @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 { try {
if(key.compareTo(AbstractStorageUsageRecord.DATA_VOLUME)==0){ if(key.compareTo(AbstractStorageUsageRecord.DATA_VOLUME)==0){

View File

@ -28,9 +28,9 @@ public class NotEmptyValidator implements FieldAction{
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @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{ try{
if(isValid(value)){ if(isValid((Serializable) value)){
return value; return value;
} }
}catch(Exception e){ }catch(Exception e){

View File

@ -14,7 +14,7 @@ public class NotNullValidator implements FieldAction {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @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){ if(value!=null){
return value; return value;
} }

View File

@ -16,7 +16,7 @@ public class ValidDataTypeValidator implements FieldAction {
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Override @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){ if(value instanceof DataType){
return value; return value;
} }

View File

@ -47,7 +47,7 @@ public class ValidIPValidator implements FieldAction{
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @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 { try {
if(isIpAddress((String) value)){ if(isIpAddress((String) value)){
return (String) value; return (String) value;

View File

@ -15,7 +15,7 @@ public class ValidIntegerValidator implements FieldAction {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @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){ if(value instanceof Integer){
return value; return value;
} }

View File

@ -15,7 +15,7 @@ public class ValidLongValidator implements FieldAction {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @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){ if(value instanceof Long){
return value; return value;
} }

View File

@ -16,7 +16,7 @@ public class ValidOperationResultValidator implements FieldAction {
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Override @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){ if(value instanceof OperationResult){
return value; return value;
} }

View File

@ -17,7 +17,7 @@ public class ValidOperationTypeValidator implements FieldAction {
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Override @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){ if(value instanceof OperationType){
return value; return value;
} }

View File

@ -15,7 +15,7 @@ public class ValidURIValidator implements FieldAction {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @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 { try {
if(value instanceof URI){ if(value instanceof URI){
return value; return value;

View File

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