Commit 70bbf695 authored by George Adrian Stoica's avatar George Adrian Stoica

fixes related to custom and standard properties from MR !6

parent f529796c
Pipeline #53417 passed with stage
in 2 minutes and 10 seconds
......@@ -18,6 +18,12 @@ public class MetaData {
*/
public final static String DESCRIPTION_PROPERTY = "description";
/**
* the list containing standard properties associated to location metadata
*/
final public static List<String> STD_PROPERTIES = Collections.unmodifiableList(Arrays.asList(NAME_PROPERTY, DESCRIPTION_PROPERTY));
private Collection<String> tags;
private List<String> properties;
......@@ -279,13 +285,32 @@ public class MetaData {
}
}
/**
* check if a certain property is custom or standard
* a property is standard when the name is found in STD_PROPERTIES
* @param propertyName the property name to check
* @return true if custom false if standard prop
*/
public boolean isCustomProperty(String propertyName) {
for (String knownPropertyName : STD_PROPERTIES) {
if (propertyName == knownPropertyName) {
return false;
}
}
return true;
}
/**
* 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
* @return true if there are any properties apart from standard ones and false otherwise
*/
public boolean hasCustomProperties() {
return hasOtherProperties(NAME_PROPERTY, DESCRIPTION_PROPERTY);
for (int i = 0; i < this.properties.size(); i = i + 2) {
String propertyName = this.properties.get(i);
if(isCustomProperty(propertyName)) return true;
}
return false;
}
/**
......@@ -294,16 +319,19 @@ public class MetaData {
* @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;
outer: for (int i = 0; i < this.properties.size(); i = i + 2) {
String propertyName = this.properties.get(i);
for (String knownPropertyName : propertyNames) {
if (propertyName == knownPropertyName) {
continue outer;
}
return true;
}
}
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