@Override public Optional<ImmutableTable> findForeignTable() { return foreignTable.getOrCompute(() -> ForeignKeyColumn.super.findForeignTable() .map(ImmutableTable.class::cast) ); }
public static Optional<? extends ForeignKeyColumn> getForeignKey(Table table, Column column) { requireNonNulls(table, column); return table.foreignKeys() .filter(HasEnabled::test) .filter(fk -> fk.foreignKeyColumns().count() == 1) // We can only handle one column FKs... .flatMap(ForeignKey::foreignKeyColumns) .filter(fkc -> fkc.findForeignTable().map(Table::isEnabled).orElse(false)) // We can only handle FKs pointing to an enabled Table .filter(fkc -> fkc.findForeignColumn().map(Column::isEnabled).orElse(false)) // We can only handle FKs pointing to an enabled column .filter(fkc -> DocumentDbUtil.isSame(column, fkc.findColumn().orElse(null))) .findFirst(); }
public FkHolder(Injector injector, ForeignKey fk) { requireNonNull(fk); this.codeGenerationComponent = injector.getOrThrow(CodeGenerationComponent.class); this.fk = fk; this.fkc = fk.foreignKeyColumns().findFirst().orElseThrow(this::noEnabledForeignKeyException); this.column = fkc.findColumn().orElseThrow(this::couldNotFindLocalColumnException); this.table = ancestor(column, Table.class).orElseThrow(NoSuchElementException::new); this.foreignColumn = fkc.findForeignColumn().orElseThrow(this::foreignKeyWasNullException); this.foreignTable = fkc.findForeignTable().orElseThrow(this::foreignKeyWasNullException); }
/** * A helper method for accessing the foreign {@link Column} referenced by * this key. * * @return the foreign {@link Column} referenced by this */ default Optional<? extends Column> findForeignColumn() { return findForeignTable() .flatMap(table -> table.columns() .filter(col -> col.getId().equals(getForeignColumnName())) .findAny() ); }
final Type fkType = new TranslatorSupport<>(injector, fkc.findForeignTable().orElseThrow( () -> new SpeedmentException( "Could not find referenced foreign table '"
public final ObjectBinding<TableProperty> foreignTableProperty() { return createObjectBinding( () -> ForeignKeyColumn.super.findForeignTable() .map(TableProperty.class::cast) .orElse(null), foreignTableNameProperty() ); }
public static Optional<? extends ForeignKeyColumn> getForeignKey(Table table, Column column) { requireNonNulls(table, column); return table.foreignKeys() .filter(HasEnabled::test) .filter(fk -> fk.foreignKeyColumns().count() == 1) // We can only handle one column FKs... .flatMap(ForeignKey::foreignKeyColumns) .filter(fkc -> fkc.findForeignTable().map(Table::isEnabled).orElse(false)) // We can only handle FKs pointing to an enabled Table .filter(fkc -> fkc.findForeignColumn().map(Column::isEnabled).orElse(false)) // We can only handle FKs pointing to an enabled column .filter(fkc -> DocumentDbUtil.isSame(column, fkc.findColumn().orElse(null))) .findFirst(); }
public FkHolder(Injector injector, ForeignKey fk) { requireNonNull(fk); this.codeGenerationComponent = injector.getOrThrow(CodeGenerationComponent.class); this.fk = fk; this.fkc = fk.foreignKeyColumns().findFirst().orElseThrow(this::noEnabledForeignKeyException); this.column = fkc.findColumn().orElseThrow(this::couldNotFindLocalColumnException); this.table = ancestor(column, Table.class).orElseThrow(NoSuchElementException::new); this.foreignColumn = fkc.findForeignColumn().orElseThrow(this::foreignKeyWasNullException); this.foreignTable = fkc.findForeignTable().orElseThrow(this::foreignKeyWasNullException); }
final Type fkType = new TranslatorSupport<>(injector, fkc.findForeignTable().orElseThrow( () -> new SpeedmentException( "Could not find referenced foreign table '"