/** * Returns a new {@link PolicyReferenceTag}. * * @param entityId the ID of the entity referencing the policy. * @param policyTag the {@link PolicyTag}. * @return a new {@link PolicyReferenceTag}. */ public static PolicyReferenceTag of(final String entityId, final PolicyTag policyTag) { return new PolicyReferenceTag(entityId, policyTag); }
/** * Returns a new {@link PolicyReferenceTag}. * * @param entityId the ID of the entity referencing the policy. * @param policyTag the {@link PolicyTag}. * @return a new {@link PolicyReferenceTag}. */ public static PolicyReferenceTag of(final String entityId, final PolicyTag policyTag) { return new PolicyReferenceTag(entityId, policyTag); }
/** * Creates a new {@link PolicyReferenceTag} from a JSON object. * * @param jsonObject the JSON object of which a new {@link PolicyReferenceTag} is to be created. * @return the {@link PolicyReferenceTag} which was created from the given JSON object. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws IllegalArgumentException if {@code jsonObject} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} is not valid JSON. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the passed in {@code jsonObject} was not in the * expected format. */ public static PolicyReferenceTag fromJson(final JsonObject jsonObject) { final String extractedEntityId = jsonObject.getValueOrThrow(JsonFields.ENTITY_ID); final String extractedPolicyId = jsonObject.getValueOrThrow(JsonFields.POLICY_ID); final long extractedPolicyRev = jsonObject.getValueOrThrow(JsonFields.POLICY_REV); final PolicyTag extractedPolicyTag = PolicyTag.of(extractedPolicyId, extractedPolicyRev); return new PolicyReferenceTag(extractedEntityId, extractedPolicyTag); }
/** * Creates a new {@link PolicyReferenceTag} from a JSON object. * * @param jsonObject the JSON object of which a new {@link PolicyReferenceTag} is to be created. * @return the {@link PolicyReferenceTag} which was created from the given JSON object. * @throws NullPointerException if {@code jsonObject} is {@code null}. * @throws IllegalArgumentException if {@code jsonObject} is empty. * @throws org.eclipse.ditto.json.JsonParseException if the passed in {@code jsonObject} is not valid JSON. * @throws org.eclipse.ditto.json.JsonMissingFieldException if the passed in {@code jsonObject} was not in the * expected format. */ public static PolicyReferenceTag fromJson(final JsonObject jsonObject) { final String extractedEntityId = jsonObject.getValueOrThrow(JsonFields.ENTITY_ID); final String extractedPolicyId = jsonObject.getValueOrThrow(JsonFields.POLICY_ID); final long extractedPolicyRev = jsonObject.getValueOrThrow(JsonFields.POLICY_REV); final PolicyTag extractedPolicyTag = PolicyTag.of(extractedPolicyId, extractedPolicyRev); return new PolicyReferenceTag(extractedEntityId, extractedPolicyTag); }