public static void validateField(String name, Class<?> keyType, Class<?> valueType, Object o) { ConfigValidationUtils.NestableFieldValidator validator = ConfigValidationUtils.mapFv(keyType, valueType, false); validator.validateField(name, o); }
public static void validateField(String name, Class<?> type, Object o) { ConfigValidationUtils.NestableFieldValidator validator = ConfigValidationUtils.listFv(type, false); validator.validateField(name, o); }
@Override public void validateField(String name, Object o, ClassLoader classLoader) { validateField(name, this.includeZero, o); } }
@EqualsAndHashCode @ToString @isValidSourceConfig public class SourceConfig { @NotNull private String tenant; @NotNull private String namespace; @NotNull private String name; private String className; @NotNull @isValidTopicName private String topicName; @isImplementationOfClass(implementsClass = SerDe.class) private String serdeClassName; @isPositiveNumber private int parallelism = 1; private FunctionConfig.ProcessingGuarantees processingGuarantees; @isValidResources private Resources resources; @isFileExists private String archive;
@EqualsAndHashCode @ToString @isValidSinkConfig public class SinkConfig { @NotNull private String tenant; @NotNull private String namespace; @NotNull private String name; private String className; @isMapEntryCustom(keyValidatorClasses = { ValidatorImpls.TopicNameValidator.class }, valueValidatorClasses = { ValidatorImpls.SerdeValidator.class }) private Map<String, String> topicToSerdeClassName; @isValidTopicName private String topicsPattern; @isMapEntryCustom(keyValidatorClasses = { ValidatorImpls.TopicNameValidator.class }) private Map<String, String> topicToSchemaType; @isPositiveNumber private int parallelism = 1; private FunctionConfig.ProcessingGuarantees processingGuarantees; private boolean retainOrdering; @isValidResources private Resources resources;
@Override public void validateField(String name, Object o, ClassLoader classLoader) { FunctionConfig functionConfig = (FunctionConfig) o; doCommonChecks(functionConfig); if (functionConfig.getRuntime() == FunctionConfig.Runtime.JAVA) { if (classLoader != null) { doJavaChecks(functionConfig, name, classLoader); } } else { doPythonChecks(functionConfig, name); } } }
public static void validateConfig(Object config, String runtimeType, ClassLoader classLoader) { for (Field field : config.getClass().getDeclaredFields()) { Object value; field.setAccessible(true); try { value = field.get(config); } catch (IllegalAccessException e) { throw new RuntimeException(e); } validateField(field, value, Runtime.valueOf(runtimeType), classLoader); } validateClass(config, Runtime.valueOf(runtimeType), classLoader); }
@Override public void validateField(String name, Object o, ClassLoader classLoader) { new ValidatorImpls.ImplementsClassValidator(Schema.class).validateField(name, o, classLoader); } }
/** * Returns a new NestableFieldValidator for a Map of key to val. * * @param key the Class of keys in the map * @param val the Class of values in the map * @param notNull whether or not a value of null is valid * @return a NestableFieldValidator for a Map of key to val */ public static NestableFieldValidator mapFv(Class key, Class val, boolean notNull) { return mapFv(fv(key, false), fv(val, false), notNull); }
/** * Returns a new NestableFieldValidator for a List of the given Class. * * @param cls the Class of elements composing the list * @param notNull whether or not a value of null is valid * @return a NestableFieldValidator for a list of the given class */ public static NestableFieldValidator listFv(Class cls, boolean notNull) { return listFv(fv(cls, notNull), notNull); }
@Override public void validateField(String name, Object o, ClassLoader classLoader) { if (o == null) { return; } if (!(o instanceof WindowConfig)) { throw new IllegalArgumentException(String.format("Field '%s' must be of WindowConfig type!", name)); } WindowConfig windowConfig = (WindowConfig) o; validateWindowConfig(windowConfig); } }
@Override public void validateField(String name, Object o, ClassLoader classLoader) { validateField(name, this.type, o); } }
@Override public void validateField(String name, Object o, ClassLoader classLoader) { validateField(name, this.keyType, this.valueType, o); } }
@Override public void validateField(String name, Object o, ClassLoader classLoader) { validateField(name, this.type, o); } }
@Override public void validateField(String name, Object field) throws IllegalArgumentException { validateField(null, name, field); }
private static void validateSchemaType(String scheamType, Class<?> typeArg, ClassLoader clsLoader, boolean input) { validateCustomSchemaType(scheamType, typeArg, clsLoader, input); }
@Override public void validateField(String name, Object o, ClassLoader classLoader) { try { validateField(name, this.keyValidators, this.valueValidators, o, classLoader); } catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) { throw new RuntimeException(e); } } }
@Override public void validateField(String name, Object o, ClassLoader classLoader) { try { validateField(name, this.entryValidators, o, classLoader); } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException | InstantiationException e) { throw new RuntimeException(e); } } }
@Override public void validateField(String name, Object o, ClassLoader classLoader) { if (o != null && o.equals(DEFAULT_SERDE)) return; new ValidatorImpls.ImplementsClassValidator(SerDe.class).validateField(name, o, classLoader); } }
@Override public void validateField(String name, Object o, ClassLoader classLoader) { SimpleTypeValidator.validateField(name, String.class, o); if (this.acceptedValues != null) { if (!this.acceptedValues.contains((String) o)) { throw new IllegalArgumentException( "Field " + name + " is not an accepted value. Value: " + o + " Accepted values: " + this.acceptedValues); } } } }