Commit a1dc0bd2 authored by George Adrian Stoica's avatar George Adrian Stoica

Metadata fixes related to !6

* Used an ordinary for loop instead of the foreach as both values and
names are in the same list and I need to loop through names only
* Removed the intermediary result boolean variable and returned directly
without breaking the loop
* Added the has otherProperties(String ...) method
parent 1c5b82f4
......@@ -280,22 +280,37 @@ public class MetaData {
}
/**
* Convenience method to check if the metadat contains custom properties
* Convenience method to check if the metadata contains custom properties
* that is other properties than the name and description
* @return true if there are any properties apart from name and description false otherwise
*/
public boolean hasCustomProperties() {
boolean result = false;
final Iterator<String> props = this.propertyNames();
if(props.hasNext()) {
while (props.hasNext()) {
final String propName = props.next();
if((propName!=NAME_PROPERTY)&&(propName!=DESCRIPTION_PROPERTY)) {
result = true;
break;
}
return hasOtherProperties(NAME_PROPERTY, DESCRIPTION_PROPERTY);
/*for (int i = 0; i < this.properties.size(); i=i+2) {
String propertyName = this.properties.get(i);
if((propertyName != NAME_PROPERTY) && (propertyName != DESCRIPTION_PROPERTY)) {
return true;
}
}
return false;*/
}
/**
* Convenience method to check if the metadata contains properties
* other than the ones given in a list
* @return true if there are any properties not in the list, false otherwise
*/
public boolean hasOtherProperties(String ... propertyNames) {
for (int i = 0; i < this.properties.size(); i=i+2) {
String propertyName = this.properties.get(i);
boolean inList = false;
for (int j = 0; j < propertyNames.length; j++) {
String knownPropertyName = propertyNames[j];
inList = inList || (propertyName == knownPropertyName);
}
if(!inList) return true;
}
return result;
return false;
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment