/** * Locate the {@link PrimaryKeyColumn} child with the specified id if it * exists, else return an empty {@code Optional}. * * @param id the {@link HasId#getId()} of the primary key column * @return the child found or an empty {@code Optional} */ default Optional<? extends PrimaryKeyColumn> findPrimaryKeyColumn(String id) { return primaryKeyColumns().filter(child -> child.getId().equals(id)).findAny(); }
/** * Returns {@code true} if the two specified documents represents the same * element in the database. Two documents are considered same if they have * the same name and type and their parents are considered same. * * @param first the first document * @param second the second document * @return {@code true} if same, else {@code false} */ public static boolean isSame(PrimaryKeyColumn first, PrimaryKeyColumn second) { if (first.getId().equals(second.getId())) { final Table firstParent = first.getParentOrThrow(); final Table secondParent = second.getParentOrThrow(); return isSame(firstParent, secondParent); } else { return false; } }
private Stream<Column> columnsFromPks() { return primaryKeyColumns().map(pk -> { try { return pk.findColumn().get(); } catch (final NoSuchElementException ex) { throw new SpeedmentTranslatorException( "Could not find any column belonging to primary key '" + pk.getId() + "'.", ex ); } }); } }
ImmutablePrimaryKeyColumn(ImmutableTable parent, Map<String, Object> pkc) { super(parent, pkc); final PrimaryKeyColumn prototype = new PrimaryKeyColumnImpl(parent, pkc); this.id = prototype.getId(); this.name = prototype.getName(); this.ordinalPosition = prototype.getOrdinalPosition(); this.column = LazyReference.create(); }
final int ordNo = 1 + (int) pkReplacement.indexColumns().count(); final IndexColumn idxCol = mutator.addNewIndexColumn(); idxCol.mutator().setId(pkc.getId()); idxCol.mutator().setName(pkc.getName()); idxCol.mutator().setOrdinalPosition(ordNo);
final int ordNo = 1 + (int) pkReplacement.indexColumns().count(); final IndexColumn idxCol = mutator.addNewIndexColumn(); idxCol.mutator().setId(pkc.getId()); idxCol.mutator().setName(pkc.getName()); idxCol.mutator().setOrdinalPosition(ordNo);