@Override public void visitSql(String sql, Parameters parameters) { sb.append(sql); } };
public static String getClasspathResourceAsString(final Class<?> klass, final String path, boolean cache) throws IOException { if (cache) { return getClasspathResourceAsString(klass, path); } else { return _getClasspathResourceAsString(klass, path); } } public static String getClasspathResourceAsString(final Class<?> klass, final String path) throws IOException {
private NoOp(ImmutableCondition child, String key, Object value) { super(child, key, value); throw check.stateInvalid("Cannot set parameters on this condition."); }
@Override public String load(String path) { try { String p = check.notNull(path, "path is null"); check.state(p.startsWith("/"), "path should start with '/' but was: {}", path); p = p.substring(1); return ResourceUtils.getClasspathResourceAsString(p); } catch (IOException e) { throw new RuntimeException(e); } } }
public static Enum<?> enumFrom(Class<?> enumClass, String name) { Enum<?>[] enums = enumValues(enumClass); for (Enum<?> e : enums) { if (e.name().equals(name)) { return e; } } throw check.argumentInvalid("name: {} is not valid for: {}", name, enumClass); }
public static String parseFromPath(Class<?> k , final String path) { String resolved; resolved = "/" + check.notNull(ResourceUtils.resolvePath(k, path), "bug path failed: {}", path); return parseFromPath(resolved); }
public final void state(boolean expression, @Nullable String errorMessageTemplate, @Nullable Object... errorMessageArgs) { if (!expression) { throw stateException(format(errorMessageTemplate, errorMessageArgs)); } }
protected AbstractField(String propertyPath, T condition, CombineType combineType) { super(); check.argument(propertyPath != null && ! propertyPath.trim().isEmpty(), "propertyPath should not be null or blank"); this.propertyPath = propertyPath; this.condition = condition; this.combineType = combineType; }
private SqlParameterDefinition( SqlParameterConverter parameterConverter, String parameterName, String sqlName, Class<?> parameterType, int order, boolean id, boolean version, boolean generated, Optional<Enumerated> enumerated, Optional<SqlParameterObjectDefinition> objectDefinition) { super(); this.parameterName = check.notNull(parameterName, "parameterName"); this.sqlName = check.notNull(sqlName, "sqlName"); this.parameterType = check.notNull(parameterType, "parameterType"); this.order = order; this.id = id; this.version = version; this.enumerated = check.notNull(enumerated, "enumerated"); this.objectDefinition = check.notNull(objectDefinition, "objectDefinition"); this.parameterConverter = check.notNull(parameterConverter, "parameterConverter"); this.generated = generated; }
public final void argument(boolean expression, @Nullable String errorMessageTemplate, @Nullable Object... errorMessageArgs) { if (!expression) { throw argumentException(format(errorMessageTemplate, errorMessageArgs)); } }
public Path fromRelative(Path p) { check.state(p.isRelative(), "path should be relative"); final Path r; if (p.isJustHash()) { r = Path.create(this.getPathWithOutHash() + p.getFullPath()); } else { r = Path.create(this.parent().getPathWithOutHash() + "/" + p.getFullPath()); } return r; } @Override
public static Enum<?> enumFrom(Class<?> enumClass, int oridinal) { return enumValues(enumClass)[oridinal]; } public static Enum<?> enumFrom(Class<?> enumClass, String name) {
public static <T> NestedKeyValue<T> getNestedKeyValue(Map<?,?> m, Object... keys) { return _getNestedKeyValue(m, null, null, keys); }
public static String resolvePath(Class<?> c, String path) { return resolveName(c, path); }
public static Enum<?>[] enumValues(Class<?> enumClass) { try { return _enumValues(enumClass); } catch (Exception e) { throw new JirmIllegalArgumentException("Cannot dynamically resolve enum values for:" + enumClass, e); } }
@Override public ImmutableCondition bind(String key, Object value) { throw check.stateInvalid("Cannot set parameters on this condition."); }
public final STATE stateInvalid(@Nullable String errorMessageTemplate, @Nullable Object... errorMessageArgs) { throw stateException(format(errorMessageTemplate, errorMessageArgs)); }
private T doAndOr(String s) { check.argument(s != null, "operator should not be null"); if (combineType == CombineType.AND) { return condition.and(s); } else { return condition.or(s); } } }
private NoOp(ImmutableCondition child, Object value) { super(child, value); throw check.stateInvalid("Cannot set parameters on this condition."); }
@Override public ImmutableCondition with(Object ... value) { throw check.stateInvalid("Cannot set parameters on this condition."); }