package org.ovirt.engine.core.config.entity.helper;

import java.util.List;

import org.ovirt.engine.core.config.EngineConfigCLIParser;
import org.ovirt.engine.core.config.entity.ConfigKey;

public class StringValueHelper extends BaseValueHelper {

    @Override
    public String getValue(String value) {
        return value;
    }

    @Override
    public String setValue(String value) {
        return value;
    }

    @Override
    public ValidationResult validate(ConfigKey key, String value) {
        List<String> validValues = key.getValidValues();

        boolean isValid = false;
        if (validValues.isEmpty()) {
            isValid = true;
        } else {
            isValid = validValues.contains(value);
        }
        return new ValidationResult(isValid);
    }

    @Override
    public void setParser(EngineConfigCLIParser parser) {
        // NOP
    }

    @Override
    public String getHelpNote(ConfigKey key) {
        return getHelpNoteByType(key, "string");
    }

}

@@ -587,16 +587,45 @@
  false;%0A
+        String details = %22%22;%0A
         
@@ -749,16 +749,126 @@
 value);%0A
+            if (!isValid) %7B%0A                details = %22Valid values are %22+key.getValidValues();%0A            %7D%0A
         
@@ -912,16 +912,25 @@
 (isValid
+, details
 );%0A    %7D

tools : engine-config should return the list of possible VNC keyboard layouts