@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } StructField that = (StructField) o; return name.equals(that.name) && type.equals(that.type); }
final void checkType(Type expected) { if (!getType().equals(expected)) { throw new IllegalStateException( "Illegal call to getter of incorrect type. Expected: " + expected + " actual: " + getType()); } }
private void checkNonNullOfType(int columnIndex, Type expectedType, Object columnNameForError) { Type actualType = getColumnType(columnIndex); checkState( expectedType.equals(actualType), "Column %s is not of correct type: expected %s but was %s", columnNameForError, expectedType, actualType); checkNonNull(columnIndex, columnNameForError); }
@Override public final boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } AbstractValue that = (AbstractValue) o; if (!getType().equals(that.getType()) || isNull != that.isNull) { return false; } return isNull || valueEquals(that); }
PrePopulatedResultSet(Type type, Iterable<Struct> rows) { Preconditions.checkNotNull(rows); Preconditions.checkNotNull(type); Preconditions.checkArgument(type.getCode() == Type.Code.STRUCT); for (StructField field : type.getStructFields()) { if (field.getType().getCode() == Code.STRUCT) { throw new UnsupportedOperationException( "STRUCT-typed columns are not supported inside ResultSets."); } } this.type = type; this.rows = rows instanceof List<?> ? (List<Struct>) rows : Lists.newArrayList(rows); for (Struct row : rows) { Preconditions.checkArgument(row.getType().equals(type)); } }
/** * Returns a {@code STRUCT} value of {@code Type} type. * * @param type the type of the {@code STRUCT} value * @param v the struct {@code STRUCT} value. This may be {@code null} to produce a value for which * {@code isNull()} is {@code true}. If non-{@code null}, {@link Struct#getType()} must match * type. */ public static Value struct(Type type, @Nullable Struct v) { if (v == null) { Preconditions.checkArgument( type.getCode() == Code.STRUCT, "Illegal call to create a NULL struct with a non-struct type."); return new StructImpl(type); } else { Preconditions.checkArgument( type.equals(v.getType()), "Mismatch between struct value and type."); return new StructImpl(v); } }
/** * Returns an {@code ARRAY<STRUCT<...>>} value. * * @param elementType * @param v the source of element values. This may be {@code null} to produce a value for which * {@code isNull()} is {@code true}. Individual elements may also be {@code null}. */ public static Value structArray(Type elementType, @Nullable Iterable<Struct> v) { if (v == null) { Preconditions.checkArgument( elementType.getCode() == Code.STRUCT, "Illegal call to create a NULL array-of-struct with a non-struct element type."); return new StructArrayImpl(elementType, null); } List<Struct> values = immutableCopyOf(v); for (Struct value : values) { if (value != null) { Preconditions.checkArgument( value.getType().equals(elementType), "Members of v must have type %s (found %s)", elementType, value.getType()); } } return new StructArrayImpl(elementType, values); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Struct)) { return false; } Struct that = (Struct) o; if (!getType().equals(that.getType())) { return false; } for (int i = 0; i < getColumnCount(); ++i) { if (!Objects.equals(getAsObject(i), that.getAsObject(i))) { return false; } } return true; }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } StructField that = (StructField) o; return name.equals(that.name) && type.equals(that.type); }
private void checkNonNullOfType(int columnIndex, Type expectedType, Object columnNameForError) { Type actualType = getColumnType(columnIndex); checkState( expectedType.equals(actualType), "Column %s is not of correct type: expected %s but was %s", columnNameForError, expectedType, actualType); checkNonNull(columnIndex, columnNameForError); }
final void checkType(Type expected) { if (!getType().equals(expected)) { throw new IllegalStateException( "Illegal call to getter of incorrect type. Expected: " + expected + " actual: " + getType()); } }
@Override public final boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } AbstractValue that = (AbstractValue) o; if (!getType().equals(that.getType()) || isNull != that.isNull) { return false; } return isNull || valueEquals(that); }
PrePopulatedResultSet(Type type, Iterable<Struct> rows) { Preconditions.checkNotNull(rows); Preconditions.checkNotNull(type); Preconditions.checkArgument(type.getCode() == Type.Code.STRUCT); for (StructField field : type.getStructFields()) { if (field.getType().getCode() == Code.STRUCT) { throw new UnsupportedOperationException( "STRUCT-typed columns are not supported inside ResultSets."); } } this.type = type; this.rows = rows instanceof List<?> ? (List<Struct>) rows : Lists.newArrayList(rows); for (Struct row : rows) { Preconditions.checkArgument(row.getType().equals(type)); } }
/** * Returns a {@code STRUCT} value of {@code Type} type. * * @param type the type of the {@code STRUCT} value * @param v the struct {@code STRUCT} value. This may be {@code null} to produce a value for which * {@code isNull()} is {@code true}. If non-{@code null}, {@link Struct#getType()} must match * type. */ public static Value struct(Type type, @Nullable Struct v) { if (v == null) { Preconditions.checkArgument( type.getCode() == Code.STRUCT, "Illegal call to create a NULL struct with a non-struct type."); return new StructImpl(type); } else { Preconditions.checkArgument( type.equals(v.getType()), "Mismatch between struct value and type."); return new StructImpl(v); } }
@Override public boolean equals(Object o) { if (o == this) { return true; } if (o instanceof Column) { Column that = (Column) o; return (this.name.equals(that.name())) && (this.type.equals(that.type())) && (this.columnOptions.equals(that.columnOptions())) && ((this.size == null) ? (that.size() == null) : this.size.equals(that.size())) && (this.notNull == that.notNull()); } return false; }
/** * Returns an {@code ARRAY<STRUCT<...>>} value. * * @param elementType * @param v the source of element values. This may be {@code null} to produce a value for which * {@code isNull()} is {@code true}. Individual elements may also be {@code null}. */ public static Value structArray(Type elementType, @Nullable Iterable<Struct> v) { if (v == null) { Preconditions.checkArgument( elementType.getCode() == Code.STRUCT, "Illegal call to create a NULL array-of-struct with a non-struct element type."); return new StructArrayImpl(elementType, null); } List<Struct> values = immutableCopyOf(v); for (Struct value : values) { if (value != null) { Preconditions.checkArgument( value.getType().equals(elementType), "Members of v must have type %s (found %s)", elementType, value.getType()); } } return new StructArrayImpl(elementType, values); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof Struct)) { return false; } Struct that = (Struct) o; if (!getType().equals(that.getType())) { return false; } for (int i = 0; i < getColumnCount(); ++i) { if (!Objects.equals(getAsObject(i), that.getAsObject(i))) { return false; } } return true; }