org.jvnet.hk2.component
Class DescriptorImpl

java.lang.Object
  extended by org.jvnet.hk2.component.DescriptorImpl
All Implemented Interfaces:
Descriptor

public class DescriptorImpl
extends Object
implements Descriptor

A simple Descriptor. FOR INTERNAL USE ONLY.

Author:
Jerome Dochez, Jeff Trent

Constructor Summary
DescriptorImpl()
           
DescriptorImpl(Class<?> type)
           
DescriptorImpl(Descriptor other)
           
DescriptorImpl(Descriptor other, boolean readOnly)
           
DescriptorImpl(String name, String typeName)
           
DescriptorImpl(String name, String typeName, MultiMap<String,String> metadata, Scope scope)
           
 
Method Summary
 DescriptorImpl addContract(Class<?> clazz)
           
 DescriptorImpl addContract(String contractFQCN)
           
 DescriptorImpl addMetadata(String key, String value)
           
 DescriptorImpl addName(String name)
           
 DescriptorImpl addQualifierType(String annotation)
           
protected  void assertNotReadOnly()
           
static DescriptorImpl createMerged(Descriptor d1, Descriptor d2)
           
 boolean equals(Object another)
           
 Collection<String> getContracts()
           
 MultiMap<String,String> getMetadata()
           
 Collection<String> getNames()
           
 Collection<String> getQualifiers()
           
 Scope getScope()
           
 String getTypeName()
           
 boolean hasContract(String contract)
           
 int hashCode()
           
 boolean hasName(String name)
           
 boolean hasQualifier(String qualifier)
           
static boolean isEmpty(Descriptor descriptor)
           
 boolean matches(Descriptor another)
          Returns true if this instance "matches" another instance.
static boolean matches(Descriptor d1, Descriptor d2)
           
 void setReadOnly()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DescriptorImpl

public DescriptorImpl()

DescriptorImpl

public DescriptorImpl(Class<?> type)

DescriptorImpl

public DescriptorImpl(String name,
                      String typeName)

DescriptorImpl

public DescriptorImpl(String name,
                      String typeName,
                      MultiMap<String,String> metadata,
                      Scope scope)

DescriptorImpl

public DescriptorImpl(Descriptor other)

DescriptorImpl

public DescriptorImpl(Descriptor other,
                      boolean readOnly)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object another)
Overrides:
equals in class Object

setReadOnly

public void setReadOnly()

assertNotReadOnly

protected void assertNotReadOnly()

addName

public DescriptorImpl addName(String name)

addContract

public DescriptorImpl addContract(Class<?> clazz)

addContract

public DescriptorImpl addContract(String contractFQCN)

addQualifierType

public DescriptorImpl addQualifierType(String annotation)

addMetadata

public DescriptorImpl addMetadata(String key,
                                  String value)

getNames

public Collection<String> getNames()
Specified by:
getNames in interface Descriptor

getScope

public Scope getScope()
Specified by:
getScope in interface Descriptor

getMetadata

public MultiMap<String,String> getMetadata()
Specified by:
getMetadata in interface Descriptor

getQualifiers

public Collection<String> getQualifiers()
Specified by:
getQualifiers in interface Descriptor

getContracts

public Collection<String> getContracts()
Specified by:
getContracts in interface Descriptor

hasName

public boolean hasName(String name)
Specified by:
hasName in interface Descriptor

hasQualifier

public boolean hasQualifier(String qualifier)
Specified by:
hasQualifier in interface Descriptor

hasContract

public boolean hasContract(String contract)
Specified by:
hasContract in interface Descriptor

getTypeName

public String getTypeName()
Specified by:
getTypeName in interface Descriptor

matches

public boolean matches(Descriptor another)
Returns true if this instance "matches" another instance.

Matching considers each attribute of the descriptor one by one. For non-null attributes, equality checks are made. If the this instance contains a null value (or empty for the case for collections) then the result for that field is true as well. For non-null and non- empty collections, this instance must be a proper subset of the other.

Parameters:
another - the other Descriptor to compare against
Returns:
true if all fields in this instance matches another

matches

public static boolean matches(Descriptor d1,
                              Descriptor d2)

isEmpty

public static boolean isEmpty(Descriptor descriptor)

createMerged

public static DescriptorImpl createMerged(Descriptor d1,
                                          Descriptor d2)


Copyright © 2011 Oracle Corporation. All Rights Reserved.