@Test public void testFromPreferenceHeader$validValues() throws Exception { assertThat(ContentPreferencesUtils.fromPreferenceHeader(MIXED_PREFERENCES_INCLUDE_OMIT),equalTo(COMPOSITE_PREFERENCES)); assertThat(ContentPreferencesUtils.fromPreferenceHeader(MIXED_PREFERENCES_OMIT_INCLUDE),equalTo(COMPOSITE_PREFERENCES)); assertThat(ContentPreferencesUtils.fromPreferenceHeader(SINGLE_INCLUDE_PREFERENCE),equalTo(SINGLE_INCLUDE)); assertThat(ContentPreferencesUtils.fromPreferenceHeader(MULTIPLE_INCLUDE_PREFERENCE),equalTo(MULTIPLE_INCLUDES)); assertThat(ContentPreferencesUtils.fromPreferenceHeader(MULTIPLE_OMIT_PREFERENCES),equalTo(MULTIPLE_OMITS)); }
public static ContentPreferences fromPreferenceHeader(String header) { checkNotNull("Preference header cannot be null"); String[] preferenceParts = header.split(";"); validatePrefix(header, preferenceParts[0]); ContentPreferencesBuilder builder = ContentPreferences.builder(); if(preferenceParts.length==1) { throw new InvalidPreferenceHeaderException("Could not parse preference ("+header+"): invalid return representation preference configuration"); } populatePreferences(builder,Arrays.copyOfRange(preferenceParts,1,preferenceParts.length,String[].class)); return builder.build(); }
ContentPreferencesUtils { public static ContentPreferences fromPreferenceHeader(String header) { checkNotNull("Preference header cannot be null"); String[] preferenceParts = header.split(";"); validatePrefix(header, preferenceParts[0]); ContentPreferencesBuilder builder = ContentPreferences.builder(); if(preferenceParts.length==1) { throw new InvalidPreferenceHeaderException("Could not parse preference ("+header+"): invalid return representation preference configuration"); } populatePreferences(builder,Arrays.copyOfRange(preferenceParts,1,preferenceParts.length,String[].class)); return builder.build(); } }
ContentPreferencesUtils { public static ContentPreferences fromPreferenceHeader(String header) { checkNotNull("Preference header cannot be null"); String[] preferenceParts = header.split(";"); validatePrefix(header, preferenceParts[0]); ContentPreferencesBuilder builder = ContentPreferences.builder(); if(preferenceParts.length==1) { throw new InvalidPreferenceHeaderException("Could not parse preference ("+header+"): invalid return representation preference configuration"); } populatePreferences(builder,Arrays.copyOfRange(preferenceParts,1,preferenceParts.length,String[].class)); return builder.build(); } private  ContentPreferencesUtils(); }
ContentPreferencesUtils { public static ContentPreferences fromPreferenceHeader(String header) { checkNotNull("Preference header cannot be null"); String[] preferenceParts = header.split(";"); validatePrefix(header, preferenceParts[0]); ContentPreferencesBuilder builder = ContentPreferences.builder(); if(preferenceParts.length==1) { throw new InvalidPreferenceHeaderException("Could not parse preference ("+header+"): invalid return representation preference configuration"); } populatePreferences(builder,Arrays.copyOfRange(preferenceParts,1,preferenceParts.length,String[].class)); return builder.build(); } private  ContentPreferencesUtils(); static ContentPreferences fromPreferenceHeader(String header); static String asPreferenceHeader(ContentPreferences contentPreferences); static String asPreferenceAppliedHeader(ContentPreferences contentPreferences); }
ContentPreferencesUtils { public static ContentPreferences fromPreferenceHeader(String header) { checkNotNull("Preference header cannot be null"); String[] preferenceParts = header.split(";"); validatePrefix(header, preferenceParts[0]); ContentPreferencesBuilder builder = ContentPreferences.builder(); if(preferenceParts.length==1) { throw new InvalidPreferenceHeaderException("Could not parse preference ("+header+"): invalid return representation preference configuration"); } populatePreferences(builder,Arrays.copyOfRange(preferenceParts,1,preferenceParts.length,String[].class)); return builder.build(); } private  ContentPreferencesUtils(); static ContentPreferences fromPreferenceHeader(String header); static String asPreferenceHeader(ContentPreferences contentPreferences); static String asPreferenceAppliedHeader(ContentPreferences contentPreferences); static final String PREFERENCE_APPLIED_HEADER; static final String PREFER_HEADER; }