-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
58 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/pl/wavesoftware/utils/stringify/impl/InspectingFieldImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package pl.wavesoftware.utils.stringify.impl; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import pl.wavesoftware.utils.stringify.configuration.DisplayNull; | ||
import pl.wavesoftware.utils.stringify.configuration.InspectionPoint; | ||
|
||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Modifier; | ||
|
||
/** | ||
* @author <a href="krzysztof.suszynski@wavesoftware.pl">Krzysztof Suszyński</a> | ||
* @since 2018-04-30 | ||
*/ | ||
@RequiredArgsConstructor | ||
final class InspectingFieldImpl implements InspectingField { | ||
private final InspectionPoint inspectionPoint; | ||
private final InspectFieldPredicate predicate; | ||
|
||
@Override | ||
public boolean shouldInspect() { | ||
return technically() && predicate.shouldInspect(inspectionPoint); | ||
} | ||
|
||
private boolean technically() { | ||
Field field = inspectionPoint.getField(); | ||
int mods = field.getModifiers(); | ||
return !Modifier.isStatic(mods) | ||
&& !field.isEnumConstant() | ||
&& !field.isSynthetic(); | ||
} | ||
|
||
@Override | ||
public boolean showNull() { | ||
DisplayNull displayNull = inspectionPoint.getField() | ||
.getAnnotation(DisplayNull.class); | ||
if (displayNull != null) { | ||
return displayNull.value(); | ||
} else { | ||
return DisplayNull.BY_DEFAULT; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters