Skip to content

Commit 14abe3f

Browse files
committed
refactor: remove ExperimentalAbstractSpecimen
This will remove experimental support for finding concrete implementations for abstract classes and interfaces as an alternative to proxying. Unfortunately, this experiment failed and will be discontinued.
1 parent 1991eb4 commit 14abe3f

File tree

8 files changed

+1
-670
lines changed

8 files changed

+1
-670
lines changed

src/main/java/com/github/nylle/javafixture/ClassPathScanner.java

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/main/java/com/github/nylle/javafixture/Configuration.java

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package com.github.nylle.javafixture;
22

3-
import java.io.BufferedReader;
4-
import java.io.InputStream;
5-
import java.io.InputStreamReader;
63
import java.time.Clock;
74
import java.time.Instant;
85
import java.time.ZoneOffset;
@@ -13,7 +10,6 @@ public class Configuration {
1310
private int minCollectionSize = 2;
1411
private int streamSize = 3;
1512
private boolean usePositiveNumbersOnly = false;
16-
private boolean experimentalInterfaces = false;
1713

1814
private Clock clock = Clock.fixed(Instant.now(), ZoneOffset.UTC);
1915

@@ -28,7 +24,6 @@ public class Configuration {
2824
* </ul><p>
2925
*/
3026
public Configuration() {
31-
this.experimentalInterfaces = experimentalInterfacesIsEnabled();
3227
}
3328

3429
/**
@@ -115,10 +110,6 @@ public boolean usePositiveNumbersOnly() {
115110
return this.usePositiveNumbersOnly;
116111
}
117112

118-
public boolean experimentalInterfaces() {
119-
return this.experimentalInterfaces;
120-
}
121-
122113
/**
123114
* @param streamSize the stream size when creating many objects at once
124115
* @return this {@code Configuration}
@@ -159,11 +150,6 @@ public Configuration usePositiveNumbersOnly(boolean usePositiveNumbersOnly) {
159150
return this;
160151
}
161152

162-
public Configuration experimentalInterfaces(boolean experimentalInterfaces) {
163-
this.experimentalInterfaces = experimentalInterfaces;
164-
return this;
165-
}
166-
167153
/**
168154
* Returns a new fixture with this configuration
169155
*
@@ -172,15 +158,4 @@ public Configuration experimentalInterfaces(boolean experimentalInterfaces) {
172158
public Fixture fixture() {
173159
return new Fixture(this);
174160
}
175-
176-
private boolean experimentalInterfacesIsEnabled() {
177-
try (InputStream in = this.getClass().getClassLoader().getResourceAsStream("javafixture/com.github.nylle.javafixture.experimetalInterfaces")) {
178-
if (in == null) {
179-
return false;
180-
}
181-
return new BufferedReader(new InputStreamReader(in)).lines().findFirst().map(x -> x.equals("enabled")).orElse(false);
182-
} catch (Exception ex) {
183-
return false;
184-
}
185-
}
186161
}

src/main/java/com/github/nylle/javafixture/SpecimenFactory.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.github.nylle.javafixture.specimen.ArraySpecimen;
55
import com.github.nylle.javafixture.specimen.CollectionSpecimen;
66
import com.github.nylle.javafixture.specimen.EnumSpecimen;
7-
import com.github.nylle.javafixture.specimen.ExperimentalAbstractSpecimen;
87
import com.github.nylle.javafixture.specimen.GenericSpecimen;
98
import com.github.nylle.javafixture.specimen.InterfaceSpecimen;
109
import com.github.nylle.javafixture.specimen.MapSpecimen;
@@ -49,10 +48,6 @@ public <T> ISpecimen<T> build(final SpecimenType<T> type) {
4948
}
5049

5150
if (type.isParameterized() && (type.isInterface() || type.isAbstract())) {
52-
if (context.getConfiguration().experimentalInterfaces()) {
53-
return experimentalAbstract(type);
54-
}
55-
5651
return new GenericSpecimen<>(type, context, this);
5752
}
5853

@@ -65,17 +60,10 @@ public <T> ISpecimen<T> build(final SpecimenType<T> type) {
6560
}
6661

6762
if (type.isInterface()) {
68-
if (context.getConfiguration().experimentalInterfaces()) {
69-
return experimentalAbstract(type);
70-
}
71-
7263
return new InterfaceSpecimen<>(type, context, this);
7364
}
7465

7566
if (type.isAbstract()) {
76-
if (context.getConfiguration().experimentalInterfaces()) {
77-
return experimentalAbstract(type);
78-
}
7967
return new AbstractSpecimen<>(type, context, this);
8068
}
8169

@@ -85,9 +73,5 @@ public <T> ISpecimen<T> build(final SpecimenType<T> type) {
8573

8674
return new ObjectSpecimen<>(type, context, this);
8775
}
88-
89-
private <T> ISpecimen<T> experimentalAbstract(SpecimenType<T> interfaceType) {
90-
return new ExperimentalAbstractSpecimen<>(interfaceType, new ClassPathScanner().findAllClassesFor(interfaceType), context, this);
91-
}
9276
}
9377

src/main/java/com/github/nylle/javafixture/specimen/ExperimentalAbstractSpecimen.java

Lines changed: 0 additions & 101 deletions
This file was deleted.

0 commit comments

Comments
 (0)