// Path: src/main/java/net/nextpulse/jadmin/dsl/ColumnValueTransformer.java
// @FunctionalInterface
// public interface ColumnValueTransformer {
// 
//   /**
//    * Transforms the provided column value, for example show a friendly name instead of an enum value.
//    *
//    * @param value the column value
//    * @return transformed column value, i.e. the friendly name of an enum value
//    */
//   String apply(Object value);
// }
// 
// Path: src/main/java/net/nextpulse/jadmin/dsl/InputTransformer.java
// @FunctionalInterface
// public interface InputTransformer {
//   
//   /**
//    * Transforms the provided user input, for example to hash a user provided password.
//    *
//    * @param input raw user input
//    * @return transformed user input, i.e. applying a hashing algorithm
//    */
//   String apply(String input);
// }
// 
// Path: src/main/java/net/nextpulse/jadmin/dsl/InputValidationRule.java
// @SuppressWarnings("unused")
// @FunctionalInterface
// public interface InputValidationRule {
//   
//   /**
//    * Validation rule that indicates a required field.
//    */
//   Supplier<InputValidationRule> REQUIRED = () -> (columnDefinition, userInput) -> {
//     if (StringUtils.isBlank(userInput)) {
//       throw new InvalidInputException(String.format("%s is empty but is required", columnDefinition.getName()));
//     }
//   };
//   
//   /**
//    * Validation rule that indicates a minimum length
//    */
//   Function<Integer, InputValidationRule> MINIMUM_LENGTH = (minLength) -> (columnDefinition, userInput) -> {
//     if (StringUtils.isBlank(userInput) || userInput.length() < minLength) {
//       throw new InvalidInputException(String.format("%s is less than %d characters", columnDefinition.getName(), minLength));
//     }
//   };
// 
//   /**
//    * Validation rule that indicates a minimum length or blank
//    */
//   Function<Integer, InputValidationRule> MINIMUM_LENGTH_OR_BLANK = (minLength) -> (columnDefinition, userInput) -> {
//     if (!StringUtils.isBlank(userInput) && userInput.length() < minLength) {
//       throw new InvalidInputException(String.format("%s is less than %d characters", columnDefinition.getName(), minLength));
//     }
//   };
//   
//   /**
//    * Validation rule that indicates a minimum length
//    */
//   Function<Integer, InputValidationRule> MAXIMUM_LENGTH = (maxLength) -> (columnDefinition, userInput) -> {
//     if (userInput.length() > maxLength) {
//       throw new InvalidInputException(String.format("%s is more than %d characters long", columnDefinition.getName(), maxLength));
//     }
//   };
//   
//   /**
//    * Method that will validatePostData (and optionally transform) a user's input value. If the user input is not valid, an
//    * exception is thrown, otherwise the (optionally transformed) user input is returned.
//    *
//    * @param columnDefinition
//    * @param userInput   raw (unsafe!) user data
//    * @throws InvalidInputException  if the user input is invalid
//    */
//   void validate(ColumnDefinition columnDefinition, String userInput) throws InvalidInputException;
// }


import net.nextpulse.jadmin.dsl.ColumnValueTransformer;
import net.nextpulse.jadmin.dsl.InputTransformer;
import net.nextpulse.jadmin.dsl.InputValidationRule;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
package net.nextpulse.jadmin;



/**
 * Object describing a single column of a table.
 *
 * @author yholkamp
 */
public class ColumnDefinition {

  /**
   * Column name, case sensitive
   */
  private String name;
  /**
   * JAdmin-type of this column.
   */
  private ColumnType type;

  /**
   * True if this column is part of the key identifying a row of the datasource containing this column.
   */
  private boolean keyColumn;
  private boolean editable;
  private List<InputValidationRule> validationRules = new ArrayList<>();
// Path: src/main/java/net/nextpulse/jadmin/dsl/ColumnValueTransformer.java
// @FunctionalInterface
// public interface ColumnValueTransformer {
// 
//   /**
//    * Transforms the provided column value, for example show a friendly name instead of an enum value.
//    *
//    * @param value the column value
//    * @return transformed column value, i.e. the friendly name of an enum value
//    */
//   String apply(Object value);
// }
// 
// Path: src/main/java/net/nextpulse/jadmin/dsl/InputTransformer.java
// @FunctionalInterface
// public interface InputTransformer {
//   
//   /**
//    * Transforms the provided user input, for example to hash a user provided password.
//    *
//    * @param input raw user input
//    * @return transformed user input, i.e. applying a hashing algorithm
//    */
//   String apply(String input);
// }
// 
// Path: src/main/java/net/nextpulse/jadmin/dsl/InputValidationRule.java
// @SuppressWarnings("unused")
// @FunctionalInterface
// public interface InputValidationRule {
//   
//   /**
//    * Validation rule that indicates a required field.
//    */
//   Supplier<InputValidationRule> REQUIRED = () -> (columnDefinition, userInput) -> {
//     if (StringUtils.isBlank(userInput)) {
//       throw new InvalidInputException(String.format("%s is empty but is required", columnDefinition.getName()));
//     }
//   };
//   
//   /**
//    * Validation rule that indicates a minimum length
//    */
//   Function<Integer, InputValidationRule> MINIMUM_LENGTH = (minLength) -> (columnDefinition, userInput) -> {
//     if (StringUtils.isBlank(userInput) || userInput.length() < minLength) {
//       throw new InvalidInputException(String.format("%s is less than %d characters", columnDefinition.getName(), minLength));
//     }
//   };
// 
//   /**
//    * Validation rule that indicates a minimum length or blank
//    */
//   Function<Integer, InputValidationRule> MINIMUM_LENGTH_OR_BLANK = (minLength) -> (columnDefinition, userInput) -> {
//     if (!StringUtils.isBlank(userInput) && userInput.length() < minLength) {
//       throw new InvalidInputException(String.format("%s is less than %d characters", columnDefinition.getName(), minLength));
//     }
//   };
//   
//   /**
//    * Validation rule that indicates a minimum length
//    */
//   Function<Integer, InputValidationRule> MAXIMUM_LENGTH = (maxLength) -> (columnDefinition, userInput) -> {
//     if (userInput.length() > maxLength) {
//       throw new InvalidInputException(String.format("%s is more than %d characters long", columnDefinition.getName(), maxLength));
//     }
//   };
//   
//   /**
//    * Method that will validatePostData (and optionally transform) a user's input value. If the user input is not valid, an
//    * exception is thrown, otherwise the (optionally transformed) user input is returned.
//    *
//    * @param columnDefinition
//    * @param userInput   raw (unsafe!) user data
//    * @throws InvalidInputException  if the user input is invalid
//    */
//   void validate(ColumnDefinition columnDefinition, String userInput) throws InvalidInputException;
// }


// Path: src/main/java/net/nextpulse/jadmin/ColumnDefinition.java
import net.nextpulse.jadmin.dsl.ColumnValueTransformer;
import net.nextpulse.jadmin.dsl.InputTransformer;
import net.nextpulse.jadmin.dsl.InputValidationRule;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

package net.nextpulse.jadmin;



/**
 * Object describing a single column of a table.
 *
 * @author yholkamp
 */
public class ColumnDefinition {

  /**
   * Column name, case sensitive
   */
  private String name;
  /**
   * JAdmin-type of this column.
   */
  private ColumnType type;

  /**
   * True if this column is part of the key identifying a row of the datasource containing this column.
   */
  private boolean keyColumn;
  private boolean editable;
  private List<InputValidationRule> validationRules = new ArrayList<>();
  private InputTransformer inputTransformer;