/** * 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); }
@Override public Policy build() { final Collection<Label> allLabels = getAllLabels(); final Collection<PolicyEntry> policyEntries = allLabels.stream() .map(lbl -> PoliciesModelFactory.newPolicyEntry(lbl, getFinalSubjects(lbl), getFinalResources(lbl))) .collect(Collectors.toList()); return ImmutablePolicy.of(id, lifecycle, revision, modified, policyEntries); }
/** * 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); }
.collect(Collectors.toSet()); return of(readId, readLifecycle, readRevision, readModified, policyEntries);