Skip to content

Commit

Permalink
Use Optional chain
Browse files Browse the repository at this point in the history
  • Loading branch information
tkindy committed Jul 28, 2022
1 parent d0896fd commit 6a348de
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/main/java/com/hubspot/jinjava/tree/parse/Token.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
**********************************************************************/
package com.hubspot.jinjava.tree.parse;

import com.hubspot.jinjava.JinjavaConfig;
import com.hubspot.jinjava.LegacyOverrides;
import com.hubspot.jinjava.interpret.JinjavaInterpreter;
import com.hubspot.jinjava.interpret.UnexpectedTokenException;
import java.io.Serializable;
Expand Down Expand Up @@ -91,13 +93,12 @@ public void setRightTrimAfterEnd(boolean rightTrimAfterEnd) {
* @return the content stripped of any whitespace control characters.
*/
protected final String handleTrim(String unwrapped) {
boolean parseWhitespaceControlStrictly =
JinjavaInterpreter.getCurrent() != null &&
JinjavaInterpreter
.getCurrent()
.getConfig()
.getLegacyOverrides()
.isParseWhitespaceControlStrictly();
boolean parseWhitespaceControlStrictly = JinjavaInterpreter
.getCurrentMaybe()
.map(JinjavaInterpreter::getConfig)
.map(JinjavaConfig::getLegacyOverrides)
.map(LegacyOverrides::isParseWhitespaceControlStrictly)
.orElse(false);

WhitespaceControlParser parser = parseWhitespaceControlStrictly
? WhitespaceControlParser.STRICT
Expand Down

0 comments on commit 6a348de

Please sign in to comment.