Record Class RepresentationPolicy
java.lang.Object
java.lang.Record
com.kazforge.jsonapi.representation.RepresentationPolicy
public record RepresentationPolicy(IncludePolicy includePolicy, FieldPolicy fieldPolicy, int maxIncludeDepth, int maxIncludedResources)
extends Record
Immutable application/runtime policy applied to a per-operation
RepresentationSelection.
Defaults deny include traversal, allow every selected sparse field, limit include depth to 10, and limit included resources to 100.
A selection is a request and cannot override this policy. This policy governs representation shaping only; it is not complete authorization, persistence, endpoint-security, or query policy.
-
Constructor Summary
ConstructorsConstructorDescriptionRepresentationPolicy(IncludePolicy includePolicy, FieldPolicy fieldPolicy, int maxIncludeDepth, int maxIncludedResources) Creates an instance of aRepresentationPolicyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic RepresentationPolicydefaults()Returns the default include and sparse-fieldset policy.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefieldPolicyrecord component.final inthashCode()Returns a hash code value for this object.Returns the value of theincludePolicyrecord component.intReturns the value of themaxIncludeDepthrecord component.intReturns the value of themaxIncludedResourcesrecord component.final StringtoString()Returns a string representation of this record class.withFieldPolicy(FieldPolicy policy) withIncludePolicy(IncludePolicy policy) withMaxIncludeDepth(int depth) withMaxIncludedResources(int count)
-
Constructor Details
-
RepresentationPolicy
public RepresentationPolicy(IncludePolicy includePolicy, FieldPolicy fieldPolicy, int maxIncludeDepth, int maxIncludedResources) Creates an instance of aRepresentationPolicyrecord class.- Parameters:
includePolicy- the value for theincludePolicyrecord componentfieldPolicy- the value for thefieldPolicyrecord componentmaxIncludeDepth- the value for themaxIncludeDepthrecord componentmaxIncludedResources- the value for themaxIncludedResourcesrecord component
-
-
Method Details
-
defaults
Returns the default include and sparse-fieldset policy. -
withIncludePolicy
-
withFieldPolicy
-
withMaxIncludeDepth
-
withMaxIncludedResources
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
includePolicy
Returns the value of theincludePolicyrecord component.- Returns:
- the value of the
includePolicyrecord component
-
fieldPolicy
Returns the value of thefieldPolicyrecord component.- Returns:
- the value of the
fieldPolicyrecord component
-
maxIncludeDepth
public int maxIncludeDepth()Returns the value of themaxIncludeDepthrecord component.- Returns:
- the value of the
maxIncludeDepthrecord component
-
maxIncludedResources
public int maxIncludedResources()Returns the value of themaxIncludedResourcesrecord component.- Returns:
- the value of the
maxIncludedResourcesrecord component
-