Package com.helger.web.scope.util
Class RequestFieldData
- java.lang.Object
-
- com.helger.web.scope.util.AbstractRequestFieldData
-
- com.helger.web.scope.util.RequestFieldData
-
- Direct Known Subclasses:
SessionBackedRequestFieldData
@Immutable public class RequestFieldData extends AbstractRequestFieldData
Represents a wrapper around a single request value. It allows gathering the current value, optionally using a default value.- Author:
- Philip Helger
- See Also:
for multi value data
-
-
Constructor Summary
Constructors Constructor Description RequestFieldData(RequestFieldData aRF)Copy constructorRequestFieldData(String sFieldName)Create a new request field that has no default valueRequestFieldData(String sFieldName, String sDefaultValue)Default constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)StringgetDefaultValue()StringgetRequestValue()Get the value of the request - optionally falling back to the provided default value if no such request parameter is presentprotected StringgetRequestValueWithoutDefault()Helper method to get the request value without falling back to the provided default value.inthashCode()booleanhasRequestValue(String sExpectedValue)Utility method that checks if the passed expected value matches the request parameter (considering the fallback mechanism)StringtoString()-
Methods inherited from class com.helger.web.scope.util.AbstractRequestFieldData
getFieldName, getParams
-
-
-
-
Constructor Detail
-
RequestFieldData
public RequestFieldData(@Nonnull RequestFieldData aRF)
Copy constructor- Parameters:
aRF- The request field to copy the values from. May not benull.
-
RequestFieldData
public RequestFieldData(@Nonnull @Nonempty String sFieldName)
Create a new request field that has no default value- Parameters:
sFieldName- The field name to use. May neither benullnor empty.
-
-
Method Detail
-
getDefaultValue
@Nonnull @OverrideOnDemand public String getDefaultValue()
- Returns:
- The default value to be used if no request parameter is present. Is
never
nullbut an empty string if no default value is available.
-
getRequestValueWithoutDefault
@Nullable protected final String getRequestValueWithoutDefault()
Helper method to get the request value without falling back to the provided default value.- Returns:
nullif no such request value is present
-
getRequestValue
@Nonnull public final String getRequestValue()
Get the value of the request - optionally falling back to the provided default value if no such request parameter is present- Returns:
- A single request value as string.
-
hasRequestValue
public final boolean hasRequestValue(@Nonnull String sExpectedValue)
Utility method that checks if the passed expected value matches the request parameter (considering the fallback mechanism)- Parameters:
sExpectedValue- The expected value. May not benull.- Returns:
trueif the passed value equals the actual request value
-
equals
public boolean equals(Object o)
- Overrides:
equalsin classAbstractRequestFieldData
-
hashCode
public int hashCode()
- Overrides:
hashCodein classAbstractRequestFieldData
-
toString
public String toString()
- Overrides:
toStringin classAbstractRequestFieldData
-
-