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 2009 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 package org.opensolaris.os.vp.panel.common.model; 28 29 import java.io.Serializable; 30 import java.util.*; 31 import org.opensolaris.os.vp.common.panel.ManagedObjectStatus; 32 import org.opensolaris.os.vp.util.misc.*; 33 import org.opensolaris.os.vp.util.misc.converter.Converter; 34 import org.opensolaris.os.vp.util.misc.event.*; 35 36 public interface ManagedObject<C extends ManagedObject> 37 extends IntervalEventSource, PropertyChangeEventSource, HasId, HasName, 38 Serializable { 39 40 // 41 // Inner classes 42 // 43 44 class Util { 45 // 46 // Static data 47 // 48 49 private static final Converter<ManagedObject, ManagedObjectStatus> 50 toPanelStatus = new Converter<ManagedObject, ManagedObjectStatus>() 51 { 52 @Override 53 public ManagedObjectStatus convert(ManagedObject o) { 54 return o.getStatus(); 55 } 56 }; 57 58 // 59 // Static methods 60 // 61 62 public static ManagedObjectStatus getMostSevereStatus( 63 Collection<? extends ManagedObject> objs) { 64 65 return ManagedObjectStatus.getMostSevere(CollectionUtil.convert( 66 objs, toPanelStatus)); 67 } 68 } 69 70 // 71 // Static data 72 // 73 74 /** 75 * The name of the property that is {@link #addPropertyChangeListener 76 * updated} when the enabled status of this {@code ManagedObject} changes. 77 */ 78 String PROPERTY_ENABLED = "enabled"; 79 80 /** 81 * The name of the property that is {@link #addPropertyChangeListener 82 * updated} when the value of {@link #getName} changes. 83 */ 84 String PROPERTY_NAME = "name"; 85 86 /** 87 * The name of the property that is {@link #addPropertyChangeListener 88 * updated} when the value of {@link #getStatus} changes. 89 */ 90 String PROPERTY_STATUS = "status"; 91 92 /** 93 * The name of the property that is {@link #addPropertyChangeListener 94 * updated} when the value of {@link #getStatusText} changes. 95 */ 96 String PROPERTY_STATUS_TEXT = "statusText"; 97 98 // 99 // HasId methods 100 // 101 102 /** 103 * Gets a unique identifier for this {@code ManagedObject}. This identifier 104 * should uniquely distinguish this {@code ManagedObject} from its peers, 105 * and should be consistent across all locales and invocations of the JVM. 106 * 107 * @return a non-{@code null} identifier 108 */ 109 @Override 110 String getId(); 111 112 // 113 // ManagedObject methods 114 // 115 116 /** 117 * Gets the description of this {@code ManagedObject}. 118 * 119 * @return the localized description, or {@code null} if no description 120 * is available for this {@code ManagedObject}. 121 */ 122 String getDescription(); 123 124 /** 125 * Gets the "child" {@code ManagedObject}s contained by this {@code 126 * ManagedObject}. 127 */ 128 List<C> getChildren(); 129 130 /** 131 * Gets the object which consumers of {@code getChildren()} can use to 132 * synchronize access to the list of children. 133 * 134 * @return the object that can be synchronized against to prevent 135 * changes to the children list 136 */ 137 Object getChildrenLock(); 138 139 /** 140 * Gets the status of this {@code ManagedObject}. 141 * 142 * @return a non-{@code null} status 143 */ 144 ManagedObjectStatus getStatus(); 145 146 /** 147 * Gets status text of this {@code ManagedObject}. 148 * 149 * @return the localized status text, or {@code null} if no status text 150 * is appropriate for this {@code ManagedObject}. 151 */ 152 String getStatusText(); 153 } 154