diff --git a/src/main/java/cz/startnet/utils/pgdiff/schema/PgTable.java b/src/main/java/cz/startnet/utils/pgdiff/schema/PgTable.java old mode 100755 new mode 100644 index b5b78632..45aef85e --- a/src/main/java/cz/startnet/utils/pgdiff/schema/PgTable.java +++ b/src/main/java/cz/startnet/utils/pgdiff/schema/PgTable.java @@ -33,7 +33,7 @@ public class PgTable extends PgRelation { * List of names of inherited tables. */ @SuppressWarnings("CollectionWithoutInitialCapacity") - private final List> inherits = new ArrayList>(); + private final List> inherits = new ArrayList>(); /** * WITH clause. If value is null then it is not set, otherwise can be set to * OIDS=true, OIDS=false, or storage parameters can be set. @@ -117,6 +117,7 @@ public List getConstraints() { * * @return relation kind */ + @Override public String getRelationKind() { return "TABLE"; } @@ -170,14 +171,14 @@ public String getCreationSQL(final PgSchema schema) { first = true; - for (final Pair inheritPair : inherits) { + for (final Pair inheritPair : inherits) { if (first) { first = false; } else { sbSQL.append(", "); } String inheritTableName = null; - if(schema.getName().equals(inheritPair.getL())){ + if (schema.getName().equals(inheritPair.getL())) { inheritTableName = inheritPair.getR(); } else { inheritTableName = String.format("%s.%s", inheritPair.getL(), inheritPair.getR()); @@ -209,7 +210,7 @@ public String getCreationSQL(final PgSchema schema) { sbSQL.append("SERVER "); sbSQL.append(getForeignServer()); } - + if (tablespace != null && !tablespace.isEmpty()) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append("TABLESPACE "); @@ -220,7 +221,7 @@ public String getCreationSQL(final PgSchema schema) { //Inherited column default override for (PgInheritedColumn column : getInheritedColumns()) { - if(column.getDefaultValue() != null){ + if (column.getDefaultValue() != null) { sbSQL.append(System.getProperty("line.separator")); sbSQL.append(System.getProperty("line.separator")); sbSQL.append("ALTER TABLE ONLY "); @@ -261,9 +262,9 @@ public String getCreationSQL(final PgSchema schema) { public void addInherits(final String schemaName, final String tableName) { inherits.add(new Pair(schemaName, tableName)); final PgTable inheritedTable = database.getSchema(schemaName).getTable(tableName); - for( PgColumn column : inheritedTable.getColumns() ) { - PgInheritedColumn inheritedColumn = new PgInheritedColumn(column); - inheritedColumns.add(inheritedColumn); + for (PgColumn column : inheritedTable.getColumns()) { + PgInheritedColumn inheritedColumn = new PgInheritedColumn(column); + inheritedColumns.add(inheritedColumn); } } @@ -272,7 +273,7 @@ public void addInherits(final String schemaName, final String tableName) { * * @return {@link #inherits} */ - public List> getInherits() { + public List> getInherits() { return Collections.unmodifiableList(inherits); } @@ -299,6 +300,7 @@ public String getWith() { * * @return {@link #tablespace} */ + @Override public String getTablespace() { return tablespace; } @@ -308,6 +310,7 @@ public String getTablespace() { * * @param tablespace {@link #tablespace} */ + @Override public void setTablespace(final String tablespace) { this.tablespace = tablespace; } @@ -317,6 +320,7 @@ public void setTablespace(final String tablespace) { * * @param column column */ + @Override public void addColumn(final PgColumn column) { columns.add(column); } @@ -338,6 +342,7 @@ public void addInheritedColumn(final PgInheritedColumn inheritedColumn) { * @return found inheritedColumn or null if no such inheritedColumn * has been found */ + @Override public PgInheritedColumn getInheritedColumn(final String name) { if (inherits != null && !inherits.isEmpty()) { for (PgInheritedColumn inheritedColumn : inheritedColumns) { @@ -376,6 +381,7 @@ public void addConstraint(final PgConstraint constraint) { * @return true if table contains given inheritedColumn {@code name}, * otherwise false */ + @Override public boolean containsInheritedColumn(final String name) { if (inherits != null && !inherits.isEmpty()) { for (PgInheritedColumn inheritedColumn : inheritedColumns) { @@ -431,18 +437,18 @@ public boolean isUnlogged() { public void setUnlogged(boolean unlogged) { this.unlogged = unlogged; } - + /** * Foreign Tables */ - + @Override public String getDropSQL() { - + return "DROP " + ((isForeign()) ? "FOREIGN ":"") + getRelationKind() + " " + PgDiffUtils.getDropIfExists() + PgDiffUtils.getQuotedName(getName()) + ";"; } - + public boolean isForeign() { return foreign; } @@ -450,13 +456,13 @@ public boolean isForeign() { public void setForeign(boolean foreign) { this.foreign = foreign; } - - public void setForeignServer(String server){ - foreignServer = server; + + public void setForeignServer(String server) { + foreignServer = server; } - - public String getForeignServer(){ - return foreignServer; + + public String getForeignServer() { + return foreignServer; } public Boolean hasRLSEnabled() { diff --git a/src/main/java/cz/startnet/utils/pgdiff/schema/PgView.java b/src/main/java/cz/startnet/utils/pgdiff/schema/PgView.java index 043ee1b5..79938c9d 100644 --- a/src/main/java/cz/startnet/utils/pgdiff/schema/PgView.java +++ b/src/main/java/cz/startnet/utils/pgdiff/schema/PgView.java @@ -82,6 +82,7 @@ public List getDeclaredColumnNames() { * * @return relation kind */ + @Override public String getRelationKind() { if (materialized) return "MATERIALIZED VIEW"; @@ -189,6 +190,7 @@ public String getQuery() { * * @return found column or null if no such column has been found */ + @Override public PgColumn getColumn(final String name) { PgColumn col = super.getColumn(name); if (col == null && !declareColumnNames) { @@ -210,6 +212,7 @@ public PgColumn getColumn(final String name) { * * @return true if table contains given column {@code name}, otherwise false */ + @Override public boolean containsColumn(final String name) { return true; }