class ValuePropertiesUtils {

  public static ValueProperties.Builder getAllOptional(final ValueProperties originalProperties) {
    ArgumentChecker.notNull(originalProperties, "original properties");
    final ValueProperties.Builder optionalProperties = ValueProperties.builder();
    for (String propertyName : originalProperties.getProperties()) {
      if (originalProperties.isOptional(propertyName)) {
        final Set<String> propertyValues = originalProperties.getValues(propertyName);
        if (propertyValues == null || propertyValues.isEmpty()) {
          optionalProperties.withAny(propertyName).withOptional(propertyName);
        } else {
          optionalProperties.with(propertyName, propertyValues).withOptional(propertyName);
        }
      }
    }
    return optionalProperties;
  }

}