• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 The Android Open Source Project
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 package com.android.internal.widget.remotecompose.core.operations.layout;
17 
18 import android.annotation.NonNull;
19 
20 import com.android.internal.widget.remotecompose.core.Operation;
21 import com.android.internal.widget.remotecompose.core.Operations;
22 import com.android.internal.widget.remotecompose.core.RemoteContext;
23 import com.android.internal.widget.remotecompose.core.WireBuffer;
24 import com.android.internal.widget.remotecompose.core.documentation.DocumentationBuilder;
25 
26 import java.util.List;
27 
28 public class ContainerEnd extends Operation {
29 
30     @Override
write(@onNull WireBuffer buffer)31     public void write(@NonNull WireBuffer buffer) {
32         apply(buffer);
33     }
34 
35     @NonNull
36     @Override
toString()37     public String toString() {
38         return "LIST_END";
39     }
40 
41     @Override
apply(@onNull RemoteContext context)42     public void apply(@NonNull RemoteContext context) {
43         // nothing
44     }
45 
46     @NonNull
47     @Override
deepToString(@onNull String indent)48     public String deepToString(@NonNull String indent) {
49         return (indent != null ? indent : "") + toString();
50     }
51 
52     /**
53      * The name of the class
54      *
55      * @return the name
56      */
57     @NonNull
name()58     public static String name() {
59         return "ListEnd";
60     }
61 
62     /**
63      * The OP_CODE for this command
64      *
65      * @return the opcode
66      */
id()67     public static int id() {
68         return Operations.CONTAINER_END;
69     }
70 
71     /**
72      * Write the operation on the buffer
73      *
74      * @param buffer
75      */
apply(@onNull WireBuffer buffer)76     public static void apply(@NonNull WireBuffer buffer) {
77         buffer.start(id());
78     }
79 
80     /**
81      * Read this operation and add it to the list of operations
82      *
83      * @param buffer the buffer to read
84      * @param operations the list of operations that will be added to
85      */
read(@onNull WireBuffer buffer, @NonNull List<Operation> operations)86     public static void read(@NonNull WireBuffer buffer, @NonNull List<Operation> operations) {
87         operations.add(new ContainerEnd());
88     }
89 
90     /**
91      * Populate the documentation with a description of this operation
92      *
93      * @param doc to append the description to.
94      */
documentation(@onNull DocumentationBuilder doc)95     public static void documentation(@NonNull DocumentationBuilder doc) {
96         doc.operation("Layout Operations", id(), name())
97                 .description("End tag for list of operations.");
98     }
99 }
100