|
1 /* |
|
2 * CDDL HEADER START |
|
3 * |
|
4 * The contents of this file are subject to the terms of the |
|
5 * Common Development and Distribution License (the "License"). |
|
6 * You may not use this file except in compliance with the License. |
|
7 * |
|
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 * or http://www.opensolaris.org/os/licensing. |
|
10 * See the License for the specific language governing permissions |
|
11 * and limitations under the License. |
|
12 * |
|
13 * When distributing Covered Code, include this CDDL HEADER in each |
|
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 * If applicable, add the following below this CDDL HEADER, with the |
|
16 * fields enclosed by brackets "[]" replaced with your own identifying |
|
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 * |
|
19 * CDDL HEADER END |
|
20 */ |
|
21 |
|
22 /* |
|
23 * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. |
|
24 */ |
|
25 |
|
26 package com.oracle.solaris.vp.panel.common.control; |
|
27 |
|
28 import java.util.*; |
|
29 import com.oracle.solaris.vp.util.misc.*; |
|
30 |
|
31 /** |
|
32 * The {@code Navigable} class encapsulates the information needed to |
|
33 * locate and initialize a {@link Control}. Namely, its {@link #getId |
|
34 * identifier} and optional {@link #getParameters initialization parameters}. |
|
35 * |
|
36 * @see Control |
|
37 */ |
|
38 public interface Navigable extends HasId, HasName { |
|
39 // |
|
40 // Inner classes |
|
41 // |
|
42 |
|
43 class Util { |
|
44 public static boolean equals(Navigable a, Navigable b) { |
|
45 if (a == null || b == null) { |
|
46 return a == b; |
|
47 } |
|
48 |
|
49 boolean retVal = false; |
|
50 |
|
51 if (ObjectUtil.equals(a.getId(), b.getId())) { |
|
52 Map<String, String> aParams = a.getParameters(); |
|
53 Map<String, String> bParams = b.getParameters(); |
|
54 |
|
55 int aParamSize = aParams == null ? 0 : aParams.size(); |
|
56 int bParamSize = bParams == null ? 0 : bParams.size(); |
|
57 |
|
58 if (aParamSize == bParamSize) { |
|
59 retVal = true; |
|
60 |
|
61 if (aParamSize != 0) { |
|
62 for (String name : aParams.keySet()) { |
|
63 if (!ObjectUtil.equals( |
|
64 aParams.get(name), bParams.get(name))) { |
|
65 retVal = false; |
|
66 break; |
|
67 } |
|
68 } |
|
69 } |
|
70 } |
|
71 } |
|
72 |
|
73 return retVal; |
|
74 } |
|
75 } |
|
76 |
|
77 // |
|
78 // Static data |
|
79 // |
|
80 |
|
81 /** |
|
82 * {@code Comparator} used to order a list of {@link Navigable}s by their |
|
83 * names. |
|
84 */ |
|
85 static Comparator<Navigable> NAVIGABLE_COMPARATOR = |
|
86 new Comparator<Navigable>() { |
|
87 @Override |
|
88 public int compare(Navigable a, Navigable b) { |
|
89 return a.getName().compareToIgnoreCase(b.getName()); |
|
90 } |
|
91 }; |
|
92 |
|
93 // |
|
94 // Navigable methods |
|
95 // |
|
96 |
|
97 /** |
|
98 * Gets the {@link Control} initialization parameters. |
|
99 */ |
|
100 Map<String, String> getParameters(); |
|
101 } |