Search in sources :

Example 1 with CustomProperty

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;
}
Also used : ArrayList(java.util.ArrayList) CustomProperty(org.ovirt.engine.api.model.CustomProperty)

Example 2 with CustomProperty

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;
}
Also used : CustomProperty(org.ovirt.engine.api.model.CustomProperty) CustomProperties(org.ovirt.engine.api.model.CustomProperties)

Aggregations

CustomProperty (org.ovirt.engine.api.model.CustomProperty)2 ArrayList (java.util.ArrayList)1 CustomProperties (org.ovirt.engine.api.model.CustomProperties)1