• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2011 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.sdkuilib.internal.repository.sdkman2;
18 
19 import java.util.ArrayList;
20 import java.util.List;
21 
22 abstract class PkgCategory {
23         private final Object mKey;
24         private final Object mIconRef;
25         private final List<PkgItem> mItems = new ArrayList<PkgItem>();
26         private String mLabel;
27         /** Transient flag used during incremental updates. */
28     private boolean mUnused;
29 
PkgCategory(Object key, String label, Object iconRef)30     public PkgCategory(Object key, String label, Object iconRef) {
31         mKey = key;
32         mLabel = label;
33         mIconRef = iconRef;
34     }
35 
getKey()36     public Object getKey() {
37         return mKey;
38     }
39 
getLabel()40     public String getLabel() {
41         return mLabel;
42     }
43 
setLabel(String label)44     public void setLabel(String label) {
45         mLabel = label;
46     }
47 
getIconRef()48     public Object getIconRef() {
49         return mIconRef;
50     }
51 
getItems()52     public List<PkgItem> getItems() {
53         return mItems;
54     }
55 
setUnused(boolean unused)56     public void setUnused(boolean unused) {
57         mUnused = unused;
58     }
59 
isUnused()60     public boolean isUnused() {
61         return mUnused;
62     }
63 
64     @Override
toString()65     public String toString() {
66         return String.format("%s <key=%s, label=%s, #items=%d>",
67                 this.getClass().getSimpleName(),
68                 mKey == null ? "null" : mKey.toString(),
69                 mLabel,
70                 mItems.size());
71     }
72 
73     /** {@link PkgCategory}s are equal if their internal keys are equal. */
74     @Override
hashCode()75     public int hashCode() {
76         final int prime = 31;
77         int result = 1;
78         result = prime * result + ((mKey == null) ? 0 : mKey.hashCode());
79         return result;
80     }
81 
82     /** {@link PkgCategory}s are equal if their internal keys are equal. */
83     @Override
equals(Object obj)84     public boolean equals(Object obj) {
85         if (this == obj) return true;
86         if (obj == null) return false;
87         if (getClass() != obj.getClass()) return false;
88         PkgCategory other = (PkgCategory) obj;
89         if (mKey == null) {
90             if (other.mKey != null) return false;
91         } else if (!mKey.equals(other.mKey)) return false;
92         return true;
93     }
94 }
95