/** * Sets the given revision number to this builder. * * @param revisionNumber the revision number to be set. * @return this builder to allow method chaining. */ default PolicyBuilder setRevision(final long revisionNumber) { return setRevision(PolicyRevision.newInstance(revisionNumber)); }
/** * Returns a new immutable Policy which is initialised with the specified entries. * * @param id the ID of the new Policy. * @param entries the entries of the Policy. * @return the new initialised Policy. * @throws NullPointerException if any argument is {@code null}. */ public static Policy newPolicy(final CharSequence id, final Iterable<PolicyEntry> entries) { return ImmutablePolicy.of(id, PolicyLifecycle.ACTIVE, PolicyRevision.newInstance(1), null, entries); }
/** * Returns a new immutable Policy which is initialised with the specified entries. * * @param id the ID of the new Policy. * @param entry the mandatory entry of the Policy. * @param furtherEntries additional entries of the Policy. * @return the new initialised Policy. * @throws NullPointerException if any argument is {@code null}. */ public static Policy newPolicy(final CharSequence id, final PolicyEntry entry, final PolicyEntry... furtherEntries) { checkNotNull(entry, "mandatory entry"); checkNotNull(furtherEntries, "additional policy entries"); final Collection<PolicyEntry> allEntries = new HashSet<>(1 + furtherEntries.length); allEntries.add(entry); Collections.addAll(allEntries, furtherEntries); return ImmutablePolicy.of(id, PolicyLifecycle.ACTIVE, PolicyRevision.newInstance(1), null, allEntries); }