1717import static java .lang .String .join ;
1818import static java .util .Arrays .asList ;
1919import static java .util .Arrays .stream ;
20+ import static java .util .Collections .emptyList ;
21+ import static java .util .Collections .emptySet ;
2022import static java .util .Collections .unmodifiableList ;
21- import static java .util .Objects .nonNull ;
22- import static java .util .Optional .ofNullable ;
2323import static java .util .stream .Collectors .joining ;
2424import static org .slf4j .LoggerFactory .getLogger ;
2525
26- import java .util .Collections ;
2726import java .util .HashMap ;
2827import java .util .HashSet ;
2928import java .util .List ;
@@ -87,11 +86,11 @@ public Prefer(final String preference, final List<String> include, final List<St
8786 final Set <String > params , final String handling , final Integer wait ) {
8887 this .preference = PREFER_MINIMAL .equals (preference ) ||
8988 PREFER_REPRESENTATION .equals (preference ) ? preference : null ;
90- this .include = ofNullable ( include ). orElseGet ( Collections :: emptyList );
91- this .omit = ofNullable ( omit ). orElseGet ( Collections :: emptyList );
89+ this .include = include != null ? include : emptyList ( );
90+ this .omit = omit != null ? omit : emptyList ( );
9291 this .handling = PREFER_LENIENT .equals (handling ) || PREFER_STRICT .equals (handling ) ? handling : null ;
9392 this .wait = wait ;
94- this .params = ofNullable ( params ). orElseGet ( Collections :: emptySet );
93+ this .params = params != null ? params : emptySet ( );
9594 }
9695
9796 /**
@@ -100,7 +99,7 @@ public Prefer(final String preference, final List<String> include, final List<St
10099 * @return a Prefer object or null on an invalid string
101100 */
102101 public static Prefer valueOf (final String value ) {
103- if (nonNull ( value ) ) {
102+ if (value != null ) {
104103 final Map <String , String > data = new HashMap <>();
105104 final Set <String > params = new HashSet <>();
106105 stream (value .split (";" )).map (String ::trim ).map (pref -> pref .split ("=" , 2 )).forEach (x -> {
@@ -113,7 +112,7 @@ public static Prefer valueOf(final String value) {
113112 final String waitValue = data .get (PREFER_WAIT );
114113 try {
115114 Integer wait = null ;
116- if (nonNull ( waitValue ) ) {
115+ if (waitValue != null ) {
117116 wait = parseInt (waitValue );
118117 }
119118 return new Prefer (data .get (PREFER_RETURN ), parseParameter (data .get (PREFER_INCLUDE )),
@@ -182,8 +181,10 @@ public List<String> getOmit() {
182181 }
183182
184183 private static List <String > parseParameter (final String param ) {
185- return ofNullable (param ).map (Prefer ::trimQuotes ).map (x -> asList (x .split ("\\ s+" )))
186- .orElseGet (Collections ::emptyList );
184+ if (param != null ) {
185+ return asList (trimQuotes (param ).split ("\\ s+" ));
186+ }
187+ return emptyList ();
187188 }
188189
189190 private static String trimQuotes (final String param ) {
0 commit comments