Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Simplify the depreciation process
Browse files Browse the repository at this point in the history
All public classes aren't final anymore. And all public methods of
public classes are final now. This means that it's possible to extend
classes, but it is not possible to change (override) the implemented
behavior.
  • Loading branch information
extsoft committed Oct 31, 2019
1 parent 10750fc commit 2232ccb
Show file tree
Hide file tree
Showing 25 changed files with 81 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @author Dmytro Serdiuk ([email protected])
* @version $Id$
*/
public final class CompositeStatus implements Status {
public class CompositeStatus implements Status {

private final List<Status> sources;

Expand All @@ -30,7 +30,7 @@ public CompositeStatus(List<Status> statuses) {
* @return a calculated exit code
*/
@Override
public short code() {
public final short code() {
return this.sources.stream()
.map(Status::code)
.filter(code -> code != 0)
Expand All @@ -44,7 +44,7 @@ public short code() {
* @return a count of total tests
*/
@Override
public int runCount() {
public final int runCount() {
return this.sources.stream().mapToInt(Status::runCount).sum();
}

Expand All @@ -54,7 +54,7 @@ public int runCount() {
* @return a count of failed tests
*/
@Override
public int failureCount() {
public final int failureCount() {
return this.sources.stream().mapToInt(Status::failureCount).sum();
}

Expand All @@ -64,7 +64,7 @@ public int failureCount() {
* @return a count of ignored tests
*/
@Override
public int ignoreCount() {
public final int ignoreCount() {
return this.sources.stream().mapToInt(Status::ignoreCount).sum();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @since 0.1
*/
@EqualsAndHashCode
public final class DirectoryBase implements Directory {
public class DirectoryBase implements Directory {

private final FileSystemPath fileSystemPath;

Expand All @@ -31,25 +31,25 @@ public DirectoryBase(FileSystemPath fileSystemPath) {
}

@Override
public void create() throws IOException {
public final void create() throws IOException {
Files.createDirectory(fileSystemPath.path());
}

@Override
public void remove() throws IOException {
public final void remove() throws IOException {
Files.walk(fileSystemPath.path(), FileVisitOption.FOLLOW_LINKS)
.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(java.io.File::delete);
}

@Override
public boolean exist() {
public final boolean exist() {
return fileSystemPath.exist();
}

@Override
public Path path() {
public final Path path() {
return fileSystemPath.path();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @since 0.1
*/
@EqualsAndHashCode
public final class DirectorySafe implements Directory {
public class DirectorySafe implements Directory {

private final Directory directory;

Expand All @@ -35,26 +35,26 @@ public DirectorySafe(Directory directory) {
}

@Override
public void create() throws IOException {
public final void create() throws IOException {
if (!directory.exist()) {
directory.create();
}
}

@Override
public void remove() throws IOException {
public final void remove() throws IOException {
if (directory.exist()) {
directory.remove();
}
}

@Override
public boolean exist() {
public final boolean exist() {
return directory.exist();
}

@Override
public Path path() {
public final Path path() {
return directory.path();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @version $Id$
* @since 0.1
*/
public final class DirectoryWithAutomaticCreation implements Directory {
public class DirectoryWithAutomaticCreation implements Directory {

private final Directory directory;

Expand All @@ -17,17 +17,17 @@ public DirectoryWithAutomaticCreation(Directory directory) {
}

@Override
public void create() throws IOException {
public final void create() throws IOException {
this.directory.create();
}

@Override
public void remove() throws IOException {
public final void remove() throws IOException {
this.directory.remove();
}

@Override
public Path path() {
public final Path path() {
try {
this.create();
return this.directory.path();
Expand All @@ -37,7 +37,7 @@ public Path path() {
}

@Override
public boolean exist() {
public final boolean exist() {
try {
this.create();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @version $Id$
* @since 0.1
*/
public final class DirectoryWithAutomaticDeletion implements Directory {
public class DirectoryWithAutomaticDeletion implements Directory {

private final Directory directory;

Expand All @@ -18,7 +18,7 @@ public DirectoryWithAutomaticDeletion(Directory directory) {
}

@Override
public void create() throws IOException {
public final void create() throws IOException {
Runtime.getRuntime().addShutdownHook(new Thread("ds") {
@Override
public void run() {
Expand All @@ -33,17 +33,17 @@ public void run() {
}

@Override
public void remove() throws IOException {
public final void remove() throws IOException {
directory.remove();
}

@Override
public Path path() {
public final Path path() {
return directory.path();
}

@Override
public boolean exist() {
public final boolean exist() {
return directory.exist();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @since 0.1
*/
@EqualsAndHashCode
public final class FileBase implements File {
public class FileBase implements File {

private final FileSystemPath fileSystemPath;

Expand All @@ -33,17 +33,17 @@ public FileBase(FileSystemPath fileSystemPath) {
}

@Override
public Path path() {
public final Path path() {
return fileSystemPath.path();
}

@Override
public boolean exist() {
public final boolean exist() {
return fileSystemPath.exist();
}

@Override
public void write(String data) throws IOException {
public final void write(String data) throws IOException {
Files.write(this.path(), data.getBytes());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* @since 0.1
*/
@EqualsAndHashCode
public final class FileSystemOfClasspathClasses implements FileSystem {
public class FileSystemOfClasspathClasses implements FileSystem {

private final FileSystem fileSystem;

Expand All @@ -37,7 +37,7 @@ private FileSystemOfClasspathClasses(FileSystem fileSystem) {


@Override
public List<FileSystemPath> files() throws FileSystemException {
public final List<FileSystemPath> files() throws FileSystemException {
return fileSystem.files();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
@EqualsAndHashCode
@ToString
public final class FileSystemPathBase implements FileSystemPath {
public class FileSystemPathBase implements FileSystemPath {

private final Path directory;
private final String file;
Expand All @@ -41,12 +41,12 @@ public FileSystemPathBase(Path directory, String file) {
}

@Override
public Path path() {
public final Path path() {
return directory.resolve(file);
}

@Override
public boolean exist() {
public final boolean exist() {
return Files.exists(path());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
@EqualsAndHashCode
@ToString(of = {"artifactPath"})
public final class FileSystemPathRelative implements FileSystemPath {
public class FileSystemPathRelative implements FileSystemPath {
private final FileSystemPath fromPath;
private final FileSystemPath artifactPath;

Expand All @@ -30,13 +30,13 @@ public FileSystemPathRelative(FileSystemPath fromPath, FileSystemPath artifactPa
}

@Override
public Path path() {
public final Path path() {
if (fromPath.equals(artifactPath)) return artifactPath.path();
return fromPath.path().relativize(artifactPath.path());
}

@Override
public boolean exist() {
public final boolean exist() {
throw new UnsupportedOperationException("Can't say definitely about existence of a path: " + path());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @since 0.1
*/
@EqualsAndHashCode
public final class RegexCondition implements Condition {
public class RegexCondition implements Condition {

final Pattern regex;

Expand Down Expand Up @@ -43,7 +43,7 @@ public RegexCondition(Pattern regex) {
}

@Override
public boolean applicable(String identity) {
public final boolean applicable(String identity) {
return regex.matcher(identity).matches();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author Dmytro Serdiuk ([email protected])
* @version $Id$
*/
public final class SuiteFromClasses implements SunshineSuite {
public class SuiteFromClasses implements SunshineSuite {
private final Class[] classes;

/**
Expand All @@ -23,7 +23,7 @@ public SuiteFromClasses(Class... clazz) {
}

@Override
public List<SunshineTest> tests() throws SuiteException {
public final List<SunshineTest> tests() throws SuiteException {
return Arrays.stream(this.classes).map(TestFromClass::new).collect(Collectors.toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author Dmytro Serdiuk ([email protected])
* @version $Id$
*/
public final class SuiteFromFileSystem implements SunshineSuite {
public class SuiteFromFileSystem implements SunshineSuite {
private final FileSystem fileSystem;

/**
Expand All @@ -24,7 +24,7 @@ public SuiteFromFileSystem(FileSystem fileSystem) {
}

@Override
public List<SunshineTest> tests() throws SuiteException {
public final List<SunshineTest> tests() throws SuiteException {
try {
return fileSystem.files().stream()
.map(f -> new TestFromFile(f.path().toString()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @version $Id$
* @since 0.2
*/
public final class Sun implements Star {
public class Sun implements Star {

private static final int SUNSHINE_ERROR = 12;
private final Kernel<?> core;
Expand All @@ -28,7 +28,7 @@ public Sun(Kernel<?> kernel) {
* appropriate {@link Kernel}.
*/
@Override
public void shine() {
public final void shine() {
try {
final Status status = this.core.status();
System.out.println(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @version $Id$
* @since 0.1
*/
public final class SunshineSuiteFilterable implements SunshineSuite {
public class SunshineSuiteFilterable implements SunshineSuite {

private final SunshineSuite suite;
private final Condition filter;
Expand All @@ -19,7 +19,7 @@ public SunshineSuiteFilterable(SunshineSuite suite, Condition filter) {
}

@Override
public List<SunshineTest> tests() throws SuiteException {
public final List<SunshineTest> tests() throws SuiteException {
return suite.tests().stream().filter(classTest -> classTest.match(filter)).collect(Collectors.toList());
}
}
Loading

0 comments on commit 2232ccb

Please sign in to comment.