use of org.ovirt.engine.api.model.CustomProperty in project ovirt-engine by oVirt.
the class CustomPropertiesParser method parse.
/**
* Format of @str is name=value;name=value;..
*
* @param str - The string to parse
* @param isRegex - defines if CustomProperty is used for regex or value representation
*/
public static List<CustomProperty> parse(String str, boolean isRegex) {
List<CustomProperty> ret = new ArrayList<>();
if (str != null) {
for (String envStr : str.split(";", -1)) {
String[] parts = getKeyValue(envStr);
if (parts.length == 2) {
CustomProperty env = new CustomProperty();
env.setName(parts[0]);
if (isRegex) {
env.setRegexp(parts[1]);
} else {
env.setValue(parts[1]);
}
ret.add(env);
}
}
}
return ret;
}
use of org.ovirt.engine.api.model.CustomProperty in project ovirt-engine by oVirt.
the class VmMapper method map.
@Mapping(from = String.class, to = CustomProperties.class)
public static CustomProperties map(String entity, CustomProperties template) {
CustomProperties model = template != null ? template : new CustomProperties();
if (entity != null) {
for (String envStr : entity.split(";", -1)) {
String[] parts = envStr.split("=", 2);
if (parts.length >= 1) {
CustomProperty env = new CustomProperty();
env.setName(parts[0]);
if (parts.length == 1) {
env.setValue(parts[1]);
}
model.getCustomProperties().add(env);
}
}
}
return model;
}
Aggregations