@Override public final <Z> Field<Z> cast(Field<Z> field) { return cast(field.getDataType()); }
@Override public final <Z> Field<Z> cast(Field<Z> field) { return cast(field.getDataType()); }
@SuppressWarnings("unchecked") private final <Z extends Number> Field<Z> numeric() { if (getDataType().isNumeric()) { return (Field<Z>) this; } else { return (Field<Z>) cast(BigDecimal.class); } }
@SuppressWarnings("unchecked") private final Field<String> varchar() { if (getDataType().isString()) { return (Field<String>) this; } else { return cast(String.class); } }
@SuppressWarnings("unchecked") @Override public final <Z> Field<Z> cast(Class<Z> type) { // [#2597] Prevent unnecessary casts if (getType() == type) return (Field<Z>) this; else return cast(DefaultDataType.getDataType(null, type)); }
@SuppressWarnings("unchecked") private final <Z extends Number> Field<Z> numeric() { if (getDataType().isNumeric()) { return (Field<Z>) this; } else { return (Field<Z>) cast(BigDecimal.class); } }
@SuppressWarnings("unchecked") private final <Z extends java.util.Date> Field<Z> date() { if (getDataType().isTemporal()) { return (Field<Z>) this; } else { return (Field<Z>) cast(Timestamp.class); } }
@SuppressWarnings("unchecked") @Override public final <Z> Field<Z> cast(Class<Z> type) { // [#2597] Prevent unnecessary casts if (getType() == type) { return (Field<Z>) this; } else { return cast(DefaultDataType.getDataType(null, type)); } }
@SuppressWarnings("unchecked") private final Field<String> varchar() { if (getDataType().isString()) { return (Field<String>) this; } else { return cast(String.class); } }
@SuppressWarnings("unchecked") private final <Z extends java.util.Date> Field<Z> date() { if (getDataType().isTemporal()) { return (Field<Z>) this; } else { return (Field<Z>) cast(Timestamp.class); } }
@Override public final Condition equalIgnoreCase(Field<String> value) { return DSL.lower(cast(String.class)).equal(DSL.lower(value)); }
@Override public final Condition notEqualIgnoreCase(Field<String> value) { return DSL.lower(cast(String.class)).notEqual(DSL.lower(value)); }
@Override public final Condition notEqualIgnoreCase(Field<String> value) { return DSL.lower(cast(String.class)).notEqual(DSL.lower(value)); }
@Override public final Condition equalIgnoreCase(Field<String> value) { return DSL.lower(cast(String.class)).equal(DSL.lower(value)); }
@SuppressWarnings("unchecked") @Override public final Condition isFalse() { Class<?> type = getType(); if (type == String.class) { return ((Field<String>) this).in((Collection) Utils.inline(FALSE_VALUES.toArray(new String[FALSE_VALUES.size()]))); } else if (Number.class.isAssignableFrom(type)) { return ((Field<Number>) this).equal(inline((Number) getDataType().convert(0))); } else if (Boolean.class.isAssignableFrom(type)) { return ((Field<Boolean>) this).equal(inline(false)); } else { return cast(String.class).in((Collection) Utils.inline(FALSE_VALUES.toArray(new String[FALSE_VALUES.size()]))); } }
@SuppressWarnings({ "unchecked" }) @Override public final Condition isFalse() { Class<?> type = getType(); if (type == String.class) return ((Field<String>) this).in(Tools.inline(FALSE_VALUES.toArray(EMPTY_STRING))); else if (Number.class.isAssignableFrom(type)) return ((Field<Number>) this).equal(inline((Number) getDataType().convert(0))); else if (Boolean.class.isAssignableFrom(type)) return ((Field<Boolean>) this).equal(inline(false)); else return cast(String.class).in(Tools.inline(FALSE_VALUES.toArray(EMPTY_STRING))); }
@SuppressWarnings({ "unchecked" }) @Override public final Condition isTrue() { Class<?> type = getType(); if (type == String.class) return ((Field<String>) this).in(Tools.inline(TRUE_VALUES.toArray(EMPTY_STRING))); else if (Number.class.isAssignableFrom(type)) return ((Field<Number>) this).equal(inline((Number) getDataType().convert(1))); else if (Boolean.class.isAssignableFrom(type)) return ((Field<Boolean>) this).equal(inline(true)); else return cast(String.class).in(TRUE_VALUES); }
@SuppressWarnings("unchecked") @Override public final Condition isTrue() { Class<?> type = getType(); if (type == String.class) { return ((Field<String>) this).in((Collection) Utils.inline(TRUE_VALUES.toArray(new String[TRUE_VALUES.size()]))); } else if (Number.class.isAssignableFrom(type)) { return ((Field<Number>) this).equal(inline((Number) getDataType().convert(1))); } else if (Boolean.class.isAssignableFrom(type)) { return ((Field<Boolean>) this).equal(inline(true)); } else { return cast(String.class).in(TRUE_VALUES); } }