Package org.trellisldp.common
Class Prefer
- java.lang.Object
-
- org.trellisldp.common.Prefer
-
public class Prefer extends Object
A class representing an HTTP Prefer header.- See Also:
- RFC 7240 and IANA values
-
-
Field Summary
Fields Modifier and Type Field Description static String
PREFER_HANDLING
static String
PREFER_INCLUDE
static String
PREFER_LENIENT
static String
PREFER_MINIMAL
static String
PREFER_OMIT
static String
PREFER_REPRESENTATION
static String
PREFER_RETURN
static String
PREFER_STRICT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<String>
getHandling()
Get the handling type.List<String>
getInclude()
Get the preferred include IRIs.List<String>
getOmit()
Get the preferred omit IRIs.Optional<String>
getPreference()
Get the preferred return type.boolean
getRespondAsync()
Identify whether the respond-async parameter was set.static Prefer
ofInclude(String... includes)
Build a Prefer object with a set of included IRIs.static Prefer
ofOmit(String... omits)
Build a Prefer object with a set of omitted IRIs.String
toString()
static Prefer
valueOf(String value)
Create a Prefer header representation from a header string.
-
-
-
Field Detail
-
PREFER_REPRESENTATION
public static final String PREFER_REPRESENTATION
- See Also:
- Constant Field Values
-
PREFER_MINIMAL
public static final String PREFER_MINIMAL
- See Also:
- Constant Field Values
-
PREFER_STRICT
public static final String PREFER_STRICT
- See Also:
- Constant Field Values
-
PREFER_LENIENT
public static final String PREFER_LENIENT
- See Also:
- Constant Field Values
-
PREFER_RETURN
public static final String PREFER_RETURN
- See Also:
- Constant Field Values
-
PREFER_INCLUDE
public static final String PREFER_INCLUDE
- See Also:
- Constant Field Values
-
PREFER_OMIT
public static final String PREFER_OMIT
- See Also:
- Constant Field Values
-
PREFER_HANDLING
public static final String PREFER_HANDLING
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Prefer
public Prefer(String preference, List<String> include, List<String> omit, Set<String> params, String handling)
Create a Prefer header representation.- Parameters:
preference
- the preference valueinclude
- a list of include valuesomit
- a list of omit valuesparams
- single-valued parametershandling
- the handling value
-
-
Method Detail
-
valueOf
public static Prefer valueOf(String value)
Create a Prefer header representation from a header string.- Parameters:
value
- the header value- Returns:
- a Prefer object or null on an invalid string
-
getPreference
public Optional<String> getPreference()
Get the preferred return type.- Returns:
- the preferred return type
-
getHandling
public Optional<String> getHandling()
Get the handling type.- Returns:
- the preferred handling type
-
getRespondAsync
public boolean getRespondAsync()
Identify whether the respond-async parameter was set.- Returns:
- true if the respond-async parameter was set; false otherwise
-
getInclude
public List<String> getInclude()
Get the preferred include IRIs.- Returns:
- the list of IRIs to be included in the representation
-
getOmit
public List<String> getOmit()
Get the preferred omit IRIs.- Returns:
- the list of IRIs to be omitted from the representation
-
ofInclude
public static Prefer ofInclude(String... includes)
Build a Prefer object with a set of included IRIs.- Parameters:
includes
- the IRIs to include- Returns:
- the Prefer object
-
-