001 /*****************************************************************************
002 * Copyright (C) PicoContainer Organization. All rights reserved. *
003 * ------------------------------------------------------------------------- *
004 * The software in this package is published under the terms of the BSD *
005 * style license a copy of which has been included with this distribution in *
006 * the LICENSE.txt file. *
007 * *
008 * Original code by Paul Hammant *
009 *****************************************************************************/
010 package org.picocontainer.containers;
011
012 import org.picocontainer.ComponentAdapter;
013 import org.picocontainer.PicoContainer;
014 import org.picocontainer.PicoVisitor;
015 import org.picocontainer.NameBinding;
016
017 import java.io.Serializable;
018 import java.util.Collection;
019 import java.util.Collections;
020 import java.util.List;
021 import java.lang.annotation.Annotation;
022 import java.lang.reflect.Type;
023
024 /**
025 * empty pico container serving as recoil damper in situations where you
026 * do not like to check whether container reference suplpied to you
027 * is null or not
028 *
029 * @author Konstantin Pribluda
030 */
031 @SuppressWarnings("serial")
032 public class EmptyPicoContainer implements PicoContainer, Serializable {
033
034 public Object getComponent(Object componentKeyOrType) {
035 return null;
036 }
037
038 public Object getComponent(Object componentKeyOrType, Type into) {
039 return null;
040 }
041
042 public <T> T getComponent(Class<T> componentType) {
043 return null;
044 }
045
046 public <T> T getComponent(Class<T> componentType, Class<? extends Annotation> binding) {
047 return null;
048 }
049
050 public List getComponents() {
051 return Collections.EMPTY_LIST;
052 }
053
054 public PicoContainer getParent() {
055 return null;
056 }
057
058 public ComponentAdapter<?> getComponentAdapter(Object componentKey) {
059 return null;
060 }
061
062 public <T> ComponentAdapter<T> getComponentAdapter(Class<T> componentType, NameBinding componentNameBinding) {
063 return null;
064 }
065
066 public <T> ComponentAdapter<T> getComponentAdapter(Class<T> componentType, Class<? extends Annotation> binding) {
067 return null;
068 }
069
070 public Collection<ComponentAdapter<?>> getComponentAdapters() {
071 return Collections.emptyList();
072 }
073
074 public <T> List<ComponentAdapter<T>> getComponentAdapters(Class<T> componentType) {
075 return Collections.emptyList();
076 }
077
078 public <T> List<ComponentAdapter<T>> getComponentAdapters(Class<T> componentType, Class<? extends Annotation> binding) {
079 return Collections.emptyList();
080 }
081
082 /**
083 * we do not have anything to do here.
084 */
085 public void accept(PicoVisitor visitor) {
086 }
087
088 public <T> List<T> getComponents(Class<T> componentType) {
089 return Collections.emptyList();
090 }
091
092 public String toString() {
093 return "(empty)";
094 }
095 }