1 /*
2  * Copyright (C) 2010 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 
17 package com.android.launcher3;
18 
19 import android.content.ComponentName;
20 
21 import androidx.annotation.Nullable;
22 
23 import com.android.launcher3.model.data.ItemInfo;
24 
25 import java.util.Optional;
26 
27 /**
28  * Meta data that is used for deferred binding. e.g., this object is used to pass information on
29  * draggable targets when they are dropped onto the workspace from another container.
30  */
31 public class PendingAddItemInfo extends ItemInfo {
32 
33     /**
34      * The component that will be created.
35      */
36     public ComponentName componentName;
37 
38     @Override
dumpProperties()39     protected String dumpProperties() {
40         return super.dumpProperties() + " componentName=" + componentName;
41     }
42 
43     /**
44      * Returns shallow copy of the object.
45      */
46     @Override
makeShallowCopy()47     public ItemInfo makeShallowCopy() {
48         PendingAddItemInfo itemInfo = new PendingAddItemInfo();
49         itemInfo.copyFrom(this);
50         itemInfo.componentName = this.componentName;
51         return itemInfo;
52     }
53 
54     @Nullable
55     @Override
getTargetComponent()56     public ComponentName getTargetComponent() {
57         return Optional.ofNullable(super.getTargetComponent()).orElse(componentName);
58     }
59 
60 }
61