components/visual-panels/core/src/java/vpanels/panel/com/oracle/solaris/vp/panel/common/model/EmptyManagedObject.java
changeset 3553 f1d133b09a8c
parent 3552 077ebe3d0d24
child 3554 ef58713bafc4
equal deleted inserted replaced
3552:077ebe3d0d24 3553:f1d133b09a8c
     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) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
       
    24  */
       
    25 
       
    26 package com.oracle.solaris.vp.panel.common.model;
       
    27 
       
    28 import java.beans.PropertyChangeListener;
       
    29 import java.util.*;
       
    30 import com.oracle.solaris.vp.util.misc.event.*;
       
    31 
       
    32 /**
       
    33  * Simple, efficient implementation of an empty ManagedObject.
       
    34  */
       
    35 public class EmptyManagedObject<T extends ManagedObject>
       
    36     implements ManagedObject<T>
       
    37 {
       
    38     private String id_ = "empty";
       
    39     private String name_ = id_;
       
    40     private String desc_ = id_;
       
    41     private IntervalListeners iListeners_ = new IntervalListeners();
       
    42     private PropertyChangeListeners pListeners_ =
       
    43 	new PropertyChangeListeners();
       
    44 
       
    45     public EmptyManagedObject() {
       
    46     }
       
    47 
       
    48     public EmptyManagedObject(String id, String name, String desc) {
       
    49 	id_ = id;
       
    50 	name_ = name;
       
    51 	desc_ = desc;
       
    52     }
       
    53 
       
    54     @Override
       
    55     public void dispose() {
       
    56     }
       
    57 
       
    58     @Override
       
    59     public String getId() {
       
    60 	return (id_);
       
    61     }
       
    62 
       
    63     @Override
       
    64     public void addPropertyChangeListener(PropertyChangeListener l) {
       
    65 	pListeners_.add(l);
       
    66     }
       
    67 
       
    68     @Override
       
    69     public void addPropertyChangeListener(String property,
       
    70 	PropertyChangeListener l) {
       
    71 
       
    72 	pListeners_.add(property, l);
       
    73     }
       
    74 
       
    75     @Override
       
    76     public String getDescription() {
       
    77 	return (desc_);
       
    78     }
       
    79 
       
    80     @Override
       
    81     public List<T> getChildren() {
       
    82 	return (Collections.emptyList());
       
    83     }
       
    84 
       
    85     @Override
       
    86     public Object getChildrenLock() {
       
    87 	return (this);
       
    88     }
       
    89 
       
    90     @Override
       
    91     public String getName() {
       
    92 	return (name_);
       
    93     }
       
    94 
       
    95     @Override
       
    96     public ManagedObjectStatus getStatus() {
       
    97 	return (ManagedObjectStatus.HEALTHY);
       
    98     }
       
    99 
       
   100     @Override
       
   101     public String getStatusText() {
       
   102 	return (null);
       
   103     }
       
   104 
       
   105     @Override
       
   106     public boolean removePropertyChangeListener(PropertyChangeListener l) {
       
   107 	return (pListeners_.remove(l));
       
   108     }
       
   109 
       
   110     @Override
       
   111     public boolean removePropertyChangeListener(String property,
       
   112 	PropertyChangeListener l) {
       
   113 
       
   114 	return (pListeners_.remove(property, l));
       
   115     }
       
   116 
       
   117     @Override
       
   118     public void addIntervalListener(IntervalListener l) {
       
   119 	iListeners_.add(l);
       
   120     }
       
   121 
       
   122     @Override
       
   123     public boolean removeIntervalListener(IntervalListener l) {
       
   124 	return (iListeners_.remove(l));
       
   125     }
       
   126 }