View Javadoc
1   /*
2    * Copyright 2022 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.bremersee.acl.spring.data.mongodb;
18  
19  import java.util.ArrayList;
20  import java.util.Collection;
21  import java.util.Collections;
22  import java.util.List;
23  import org.immutables.value.Value;
24  import org.immutables.value.Value.Style.ImplementationVisibility;
25  import org.springframework.data.mongodb.core.query.Update;
26  
27  /**
28   * The acl modification update.
29   *
30   * @author Christian Bremer
31   */
32  @Value.Immutable
33  @Value.Style(visibility = ImplementationVisibility.PACKAGE)
34  public interface AclModificationUpdate {
35  
36    /**
37     * Creates acl modification update builder.
38     *
39     * @return the acl modification update builder
40     */
41    static ImmutableAclModificationUpdate.Builder builder() {
42      return ImmutableAclModificationUpdate.builder();
43    }
44  
45    /**
46     * Gets preparation updates.
47     *
48     * @return the preparation updates
49     */
50    Collection<Update> getPreparationUpdates();
51  
52    /**
53     * Gets final update.
54     *
55     * @return the final update
56     */
57    Update getFinalUpdate();
58  
59    /**
60     * Gets updates.
61     *
62     * @return the updates
63     */
64    @Value.Derived
65    default Collection<Update> getUpdates() {
66      List<Update> updates = new ArrayList<>(getPreparationUpdates());
67      updates.add(getFinalUpdate());
68      return Collections.unmodifiableCollection(updates);
69    }
70  
71  }