Skip to content

Commit c1f0b8f

Browse files
Rename isTypeNonBlank
1 parent d13ddb9 commit c1f0b8f

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

src/main/java/io/github/malczuuu/problem4j/core/Problem.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import java.io.Serializable;
44
import java.net.URI;
55
import java.util.Map;
6-
import java.util.Objects;
76
import java.util.Set;
87

98
/**
@@ -127,8 +126,8 @@ static Extension extension(String key, Object value) {
127126
*
128127
* @return {@code true} if {@code type} is assigned to a non-blank value, {@code false} otherwise
129128
*/
130-
default boolean hasType() {
131-
return getType() != null && !Objects.equals(getType(), BLANK_TYPE);
129+
default boolean isTypeNonBlank() {
130+
return getType() != null && !getType().equals(BLANK_TYPE) && !getType().toString().isEmpty();
132131
}
133132

134133
/** Represents a single key-value extension in a {@link Problem}. */

src/test/java/io/github/malczuuu/problem4j/core/ProblemBuilderImplTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,31 @@ void givenNullURIType_shouldNotSetIt() {
2525
Problem problem = Problem.builder().type((URI) null).build();
2626

2727
assertThat(problem.getType()).isEqualTo(Problem.BLANK_TYPE);
28-
assertThat(problem.hasType()).isFalse();
28+
assertThat(problem.isTypeNonBlank()).isFalse();
2929
}
3030

3131
@Test
3232
void givenNullStringType_shouldNotSetIt() {
3333
Problem problem = Problem.builder().type((String) null).build();
3434

3535
assertThat(problem.getType()).isEqualTo(Problem.BLANK_TYPE);
36-
assertThat(problem.hasType()).isFalse();
36+
assertThat(problem.isTypeNonBlank()).isFalse();
3737
}
3838

3939
@Test
4040
void givenBlankURIType_shouldNotSetIt() {
4141
Problem problem = Problem.builder().type(Problem.BLANK_TYPE).build();
4242

4343
assertThat(problem.getType()).isEqualTo(Problem.BLANK_TYPE);
44-
assertThat(problem.hasType()).isFalse();
44+
assertThat(problem.isTypeNonBlank()).isFalse();
4545
}
4646

4747
@Test
4848
void givenBlankStringType_shouldNotSetIt() {
4949
Problem problem = Problem.builder().type(Problem.BLANK_TYPE.toString()).build();
5050

5151
assertThat(problem.getType()).isEqualTo(Problem.BLANK_TYPE);
52-
assertThat(problem.hasType()).isFalse();
52+
assertThat(problem.isTypeNonBlank()).isFalse();
5353
}
5454

5555
@Test

0 commit comments

Comments
 (0)