Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
q3769 committed Mar 21, 2023
1 parent 3aed0f9 commit cea340e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<groupId>io.github.elf4j</groupId>
<artifactId>elf4j-engine</artifactId>
<version>1.0.0</version>
<version>1.0.1</version>
<packaging>jar</packaging>
<name>elf4j-engine</name>
<description>A stand-aline Java log engine implementing the ELF4J (Easy Logging Facade for Java) API</description>
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/elf4j/engine/writer/WriterType.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ Set<LogWriter> parseWriters(Properties properties) {
}
};

private static final EnumSet<WriterType> WRITER_TYPES = EnumSet.allOf(WriterType.class);

/**
* @param properties configuration source
* @return all writers parsed from the specified properties
*/
public static Set<LogWriter> parseAllWriters(Properties properties) {
return EnumSet.allOf(WriterType.class)
.stream()
return WRITER_TYPES.stream()
.flatMap(type -> type.parseWriters(properties).stream())
.collect(Collectors.toSet());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ LogPattern translate(String patternSegment) {
return VerbatimPatternSegment.from(patternSegment);
}
};
private static final EnumSet<PatternSegmentType> PREDEFINED_PATTERN_TYPES =
private static final EnumSet<PatternSegmentType> PATTERN_SEGMENT_TYPES = EnumSet.allOf(PatternSegmentType.class);
private static final EnumSet<PatternSegmentType> PREDEFINED_PATTERN_SEGMENT_TYPES =
EnumSet.complementOf(EnumSet.of(VERBATIM));

/**
Expand Down Expand Up @@ -205,14 +206,13 @@ static Optional<String> getPatternSegmentOption(@NonNull String patternSegment)

private static boolean isPatternSegmentOfType(PatternSegmentType patternSegmentType, String patternSegment) {
if (patternSegmentType == VERBATIM) {
return PREDEFINED_PATTERN_TYPES.stream().noneMatch(type -> type.isTargetTypeOf(patternSegment));
return PREDEFINED_PATTERN_SEGMENT_TYPES.stream().noneMatch(type -> type.isTargetTypeOf(patternSegment));
}
return patternSegmentType.name().equalsIgnoreCase(patternSegment.split(":", 2)[0].trim());
}

private static LogPattern parsePatternSegment(String patternSegment) {
return EnumSet.allOf(PatternSegmentType.class)
.stream()
return PATTERN_SEGMENT_TYPES.stream()
.filter(type -> type.isTargetTypeOf(patternSegment))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(
Expand Down

0 comments on commit cea340e

Please sign in to comment.