diff --git a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/constraint/DuplicatedForeignKeys.java b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/constraint/DuplicatedForeignKeys.java index b0f00bbc..02ef30b6 100644 --- a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/constraint/DuplicatedForeignKeys.java +++ b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/constraint/DuplicatedForeignKeys.java @@ -30,7 +30,7 @@ * @since 0.13.1 */ @Immutable -public class DuplicatedForeignKeys implements DbObject, TableNameAware, ConstraintsAware { +public final class DuplicatedForeignKeys implements DbObject, TableNameAware, ConstraintsAware { private final List foreignKeys; private final List foreignKeysNames; @@ -49,7 +49,7 @@ private DuplicatedForeignKeys(@Nonnull final List foreignKeys) { */ @Nonnull @Override - public final String getName() { + public String getName() { return String.join(",", foreignKeysNames); } @@ -58,7 +58,7 @@ public final String getName() { */ @Nonnull @Override - public final PgObjectType getObjectType() { + public PgObjectType getObjectType() { return PgObjectType.CONSTRAINT; } @@ -95,7 +95,7 @@ public List getConstraints() { * {@inheritDoc} */ @Override - public final boolean equals(final Object other) { + public boolean equals(final Object other) { if (this == other) { return true; } @@ -112,7 +112,7 @@ public final boolean equals(final Object other) { * {@inheritDoc} */ @Override - public final int hashCode() { + public int hashCode() { return Objects.hash(foreignKeys); } diff --git a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/constraint/ForeignKey.java b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/constraint/ForeignKey.java index 774598f2..aa142010 100644 --- a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/constraint/ForeignKey.java +++ b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/constraint/ForeignKey.java @@ -27,7 +27,7 @@ * @see Constraint */ @Immutable -public class ForeignKey extends Constraint { +public final class ForeignKey extends Constraint { private final List columnsInConstraint; diff --git a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/context/PgContext.java b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/context/PgContext.java index c649c594..a5bb5c17 100644 --- a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/context/PgContext.java +++ b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/context/PgContext.java @@ -14,13 +14,17 @@ import java.util.Locale; import javax.annotation.Nonnull; +import javax.annotation.concurrent.Immutable; +import javax.annotation.concurrent.ThreadSafe; /** * Represents a context for running maintenance queries. * * @author Ivan Vakhrushev */ -public class PgContext { +@Immutable +@ThreadSafe +public final class PgContext { /** * Default bloat percentage threshold. diff --git a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/function/StoredFunction.java b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/function/StoredFunction.java index 0ecd51c0..37947849 100644 --- a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/function/StoredFunction.java +++ b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/function/StoredFunction.java @@ -25,7 +25,7 @@ * @since 0.7.0 */ @Immutable -public class StoredFunction implements DbObject, Comparable { +public final class StoredFunction implements DbObject, Comparable { private final String functionName; private final String functionSignature; @@ -41,7 +41,7 @@ private StoredFunction(@Nonnull final String functionName, @Nonnull final String */ @Nonnull @Override - public final String getName() { + public String getName() { return getFunctionName(); } @@ -50,7 +50,7 @@ public final String getName() { */ @Nonnull @Override - public final PgObjectType getObjectType() { + public PgObjectType getObjectType() { return PgObjectType.FUNCTION; } @@ -88,7 +88,7 @@ public String toString() { * {@inheritDoc} */ @Override - public final boolean equals(final Object other) { + public boolean equals(final Object other) { if (this == other) { return true; } @@ -106,7 +106,7 @@ public final boolean equals(final Object other) { * {@inheritDoc} */ @Override - public final int hashCode() { + public int hashCode() { return Objects.hash(functionName, functionSignature); } diff --git a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/index/DuplicatedIndexes.java b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/index/DuplicatedIndexes.java index 9620945c..b78d95d1 100644 --- a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/index/DuplicatedIndexes.java +++ b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/index/DuplicatedIndexes.java @@ -31,7 +31,7 @@ * @see TableNameAware */ @Immutable -public class DuplicatedIndexes implements DbObject, TableNameAware, IndexesAware { +public final class DuplicatedIndexes implements DbObject, TableNameAware, IndexesAware { private static final Comparator INDEX_WITH_SIZE_COMPARATOR = Comparator.comparing(IndexWithSize::getTableName) @@ -61,7 +61,7 @@ private DuplicatedIndexes(@Nonnull final List duplicatedIndexes) */ @Nonnull @Override - public final String getName() { + public String getName() { return String.join(",", indexesNames); } @@ -70,7 +70,7 @@ public final String getName() { */ @Nonnull @Override - public final PgObjectType getObjectType() { + public PgObjectType getObjectType() { return PgObjectType.INDEX; } @@ -124,7 +124,7 @@ public List getIndexNames() { * {@inheritDoc} */ @Override - public final boolean equals(final Object other) { + public boolean equals(final Object other) { if (this == other) { return true; } @@ -141,7 +141,7 @@ public final boolean equals(final Object other) { * {@inheritDoc} */ @Override - public final int hashCode() { + public int hashCode() { return Objects.hash(indexes); } diff --git a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/index/IndexWithBloat.java b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/index/IndexWithBloat.java index 43ccbee7..a3760f6d 100644 --- a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/index/IndexWithBloat.java +++ b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/index/IndexWithBloat.java @@ -22,7 +22,7 @@ * @author Ivan Vakhrushev */ @Immutable -public class IndexWithBloat extends IndexWithSize implements BloatAware { +public final class IndexWithBloat extends IndexWithSize implements BloatAware { private final long bloatSizeInBytes; private final double bloatPercentage; diff --git a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/sequence/SequenceState.java b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/sequence/SequenceState.java index 3db68d6d..07757a7d 100644 --- a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/sequence/SequenceState.java +++ b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/sequence/SequenceState.java @@ -27,7 +27,7 @@ * @since 0.12.0 */ @Immutable -public class SequenceState implements DbObject, SequenceNameAware { +public final class SequenceState implements DbObject, SequenceNameAware { private final String sequenceName; private final String dataType; @@ -84,7 +84,7 @@ public double getRemainingPercentage() { */ @Nonnull @Override - public final String getName() { + public String getName() { return getSequenceName(); } @@ -93,7 +93,7 @@ public final String getName() { */ @Nonnull @Override - public final PgObjectType getObjectType() { + public PgObjectType getObjectType() { return PgObjectType.SEQUENCE; } @@ -101,7 +101,7 @@ public final PgObjectType getObjectType() { * {@inheritDoc} */ @Override - public final boolean equals(final Object other) { + public boolean equals(final Object other) { if (this == other) { return true; } @@ -118,7 +118,7 @@ public final boolean equals(final Object other) { * {@inheritDoc} */ @Override - public final int hashCode() { + public int hashCode() { return Objects.hash(sequenceName); } diff --git a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/table/Table.java b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/table/Table.java index 35f4b6cb..ca6a14a5 100644 --- a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/table/Table.java +++ b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/table/Table.java @@ -24,7 +24,7 @@ * @author Ivan Vakhrushev */ @Immutable -public class Table implements DbObject, TableSizeAware, Comparable { +public final class Table implements DbObject, TableSizeAware, Comparable
{ private final String tableName; private final long tableSizeInBytes; @@ -39,7 +39,7 @@ private Table(@Nonnull final String tableName, final long tableSizeInBytes) { */ @Nonnull @Override - public final String getName() { + public String getName() { return getTableName(); } @@ -48,7 +48,7 @@ public final String getName() { */ @Nonnull @Override - public final PgObjectType getObjectType() { + public PgObjectType getObjectType() { return PgObjectType.TABLE; } @@ -75,7 +75,7 @@ public long getTableSizeInBytes() { * @return string representation of the internal fields of this class */ @Nonnull - final String innerToString() { + String innerToString() { return "tableName='" + tableName + '\'' + ", tableSizeInBytes=" + tableSizeInBytes; } @@ -93,7 +93,7 @@ public String toString() { * {@inheritDoc} */ @Override - public final boolean equals(final Object other) { + public boolean equals(final Object other) { if (this == other) { return true; } @@ -110,7 +110,7 @@ public final boolean equals(final Object other) { * {@inheritDoc} */ @Override - public final int hashCode() { + public int hashCode() { return Objects.hash(tableName); } diff --git a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/table/TableWithBloat.java b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/table/TableWithBloat.java index b9d290ca..9b89177b 100644 --- a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/table/TableWithBloat.java +++ b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/table/TableWithBloat.java @@ -23,7 +23,7 @@ * @author Ivan Vakhrushev */ @Immutable -public class TableWithBloat extends AbstractTableAware implements BloatAware, Comparable { +public final class TableWithBloat extends AbstractTableAware implements BloatAware, Comparable { private final long bloatSizeInBytes; private final double bloatPercentage; @@ -68,7 +68,7 @@ public String toString() { * {@inheritDoc} */ @Override - public final boolean equals(final Object other) { + public boolean equals(final Object other) { if (this == other) { return true; } @@ -85,7 +85,7 @@ public final boolean equals(final Object other) { * {@inheritDoc} */ @Override - public final int hashCode() { + public int hashCode() { return Objects.hash(table); } diff --git a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/table/TableWithMissingIndex.java b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/table/TableWithMissingIndex.java index 8a85b244..7ca2dad1 100644 --- a/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/table/TableWithMissingIndex.java +++ b/pg-index-health-model/src/main/java/io/github/mfvanek/pg/model/table/TableWithMissingIndex.java @@ -22,7 +22,7 @@ * @author Ivan Vakhrushev */ @Immutable -public class TableWithMissingIndex extends AbstractTableAware implements Comparable { +public final class TableWithMissingIndex extends AbstractTableAware implements Comparable { /** * The number of sequential scans performed on the table. @@ -79,7 +79,7 @@ public String toString() { * {@inheritDoc} */ @Override - public final boolean equals(final Object other) { + public boolean equals(final Object other) { if (this == other) { return true; } @@ -96,7 +96,7 @@ public final boolean equals(final Object other) { * {@inheritDoc} */ @Override - public final int hashCode() { + public int hashCode() { return Objects.hash(table); }