Package ca.cdr.api.security.permission
Class PermissionArgumentParser
java.lang.Object
ca.cdr.api.security.permission.PermissionArgumentParser
Parser for PermissionEnum arguments
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanhasFilter(GrantedAuthorityJson theGrantedAuthorityJson) Goofy check looking for the presence of filter expressions in an argument.parse(GrantedAuthorityJson theGrantedAuthority) Parse any authority generically.<T extends PermissionArgumentValue>
Optional<T>parse(String thePermissionArgument, PermissionArgumentFormat<T> theFormat) Parse a string against a defined format.<T extends PermissionArgumentValue>
Optional<T>parseForValue(GrantedAuthorityJson theGrantedAuthority, Class<T> theArgumentValueType) Parse the argument string from the GrantedAuthorityJson into the declared argument value type.static PermissionArgumentParserwithFhirContext(FhirContext theFhirContext) static PermissionArgumentParser
-
Method Details
-
withFhirContext
@Nonnull public static PermissionArgumentParser withFhirContext(@Nonnull FhirContext theFhirContext) -
withoutFhirContext
-
parse
Parse any authority generically. Parses the GrantedAuthorityJson argument via the declared format of the PermissionEnum. UsePermissionArgumentFormat.IPermissionComponenttype checks to extract information.- Parameters:
theGrantedAuthority- the authority (permission and argument) to parse- Returns:
- the parsed value, if the format was valid
-
parseForValue
@Nonnull public <T extends PermissionArgumentValue> Optional<T> parseForValue(@Nonnull GrantedAuthorityJson theGrantedAuthority, @Nonnull Class<T> theArgumentValueType) Parse the argument string from the GrantedAuthorityJson into the declared argument value type. It is an error to request the wrong type. Useparse(GrantedAuthorityJson)to parse for any permission.- Type Parameters:
T- the type or type component to be parsed- Parameters:
theGrantedAuthority- the permission and argument to parsetheArgumentValueType- the concrete parsed value type or a component interface- Returns:
- the parsed data, if the declared argument format agrees with theArgumentValueType
- Throws:
IllegalArgumentException- if the declared GA type does not match theArgumentValueType
-
parse
public <T extends PermissionArgumentValue> Optional<T> parse(@Nullable String thePermissionArgument, @Nonnull PermissionArgumentFormat<T> theFormat) Parse a string against a defined format.- Type Parameters:
T- The concrete argument value type (e.g.TypeInCompartmentWithOptionalFilter), for the format.- Parameters:
thePermissionArgument- the permission argument to parsetheFormat- the permission argument format- Returns:
- The value-type for the format, or empty if the string doesn't match the format.
-
hasFilter
Goofy check looking for the presence of filter expressions in an argument. Faster than a full parse.- Parameters:
theGrantedAuthorityJson- the authority to check- Returns:
- true if the permission argument type can have a filter AND the filter is present
-