public static Stream<? extends Document> traverseOver(ForeignKey foreignKey) { return Stream.concat(foreignKey.foreignKeyColumns(), foreignKey.foreignKeyColumns().flatMap(DocumentDbUtil::traverseOver)); }
public static <T> Stream<T> traverseOver(ForeignKey fk, Class<T> clazz) { if (ForeignKeyColumn.class.isAssignableFrom(clazz)) { return fk.foreignKeyColumns().map(clazz::cast); } else { return fk.foreignKeyColumns().flatMap(fcc -> traverseOver(fcc, clazz)); } }
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); }
.filter(fk -> fksThatNeedNewNames.contains(fk.getId())) .forEach(fk -> { final Set<String> thisSet = fk.foreignKeyColumns() .map(ForeignKeyColumn::getId) .collect(toSet());
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); }
.filter(fk -> fksThatNeedNewNames.contains(fk.getId())) .forEach(fk -> { final Set<String> thisSet = fk.foreignKeyColumns() .map(ForeignKeyColumn::getId) .collect(toSet());