Skip to content

Commit 327b3f4

Browse files
committed
deprecate createOptional interface
1 parent 7028145 commit 327b3f4

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

README.md

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ ArrayList:
115115
### Customize Property With Lambda
116116
```java
117117
TestDto result = fixture.build(TestDto.class)
118-
.with(x -> x.myPublicField = 123)
119118
.with(x -> x.setMyPrivateField("HELLO!"))
119+
.with(x -> x.myPublicField = 123)
120120
.create();
121121
```
122122
#### Sample Result
@@ -186,18 +186,6 @@ Optional result = fixture.create(SpecimenType.fromClass(Optional.class));
186186
Optional result = fixture.create(Optional.class); // convenience method for above
187187
```
188188

189-
## Optionals
190-
To quickly create an `Optional<T>` of your desired type `T` without the need to use `SpecimenType<Optional<T>>` as described [above](#generics), here is some syntactic sugar:
191-
```java
192-
Optional<String> result = fixture.createOptional(String.class);
193-
```
194-
Or with customisation:
195-
```java
196-
Optional<TestDto> result = fixture.build(TestDto.class)
197-
.without("myPublicField")
198-
.createOptional();
199-
```
200-
201189
## Constructor
202190
There might be some cases when you want to create an object not by instantiating it and setting all fields, but by calling one of its constructors and feeding it random values.
203191
```java

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ public <T> T create(final Class<T> type) {
8080
* @param type the {@code Class<T>} based on which the object is created
8181
* @param <T> the type of the object to be created
8282
* @return a new {@code Optional} of the specified {@code Class<T>}
83+
*
84+
* This feature is deprecated without replacement.
8385
*/
86+
@Deprecated(forRemoval = true)
8487
public <T> Optional<T> createOptional(final Class<T> type) {
8588
return new SpecimenBuilder<T>(SpecimenType.fromClass(type), configuration).createOptional();
8689
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ public T create() {
3535

3636
/**
3737
* @return a new {@code Optional<T>} based on this {@code ISpecimenBuilder<T>}
38+
*
39+
* This feature is deprecated without replacement.
3840
*/
41+
@Deprecated(forRemoval = true)
3942
@Override
4043
public Optional<T> createOptional() {
4144
return Optional.of(create());

0 commit comments

Comments
 (0)