Package com.opencloud.sentinel.common
Class ServiceIDLookupImpl
- java.lang.Object
-
- com.opencloud.sentinel.common.ServiceIDLookupImpl
-
- All Implemented Interfaces:
ServiceIDLookup,java.io.Serializable,java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.Long>>
public final class ServiceIDLookupImpl extends java.lang.Object implements ServiceIDLookup, java.io.Serializable
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ServiceIDLookupImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)longgetIDForName(java.lang.String name)Lookup the numerical identifier which is currently mapped to a particular service name in the DiameterCharging service's serviceID configuration.long[]getIds()java.lang.String[]getNames()java.lang.StringgetServiceNameForID(long id)Lookup the name which is currently mapped to a particular service ID in the DiameterCharging service's service ID configuration.inthashCode()java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.Long>>iterator()voidput(long id, java.lang.String name)Used by the codec to decode an id/name entry.voidsetNewConfiguration(long[] ids, java.lang.String[] names)Re-initialize the configuration with a new set of IDs and names.java.lang.StringtoString()
-
-
-
Method Detail
-
getServiceNameForID
public java.lang.String getServiceNameForID(long id)
Description copied from interface:ServiceIDLookupLookup the name which is currently mapped to a particular service ID in the DiameterCharging service's service ID configuration.- Specified by:
getServiceNameForIDin interfaceServiceIDLookup- Parameters:
id- The service ID as it appears in the MSCC's 'serviceIDs' AVP- Returns:
- The name currently mapped to the ID or
nullif there is currently no name mapped to the ID.
-
getIDForName
public long getIDForName(java.lang.String name)
Description copied from interface:ServiceIDLookupLookup the numerical identifier which is currently mapped to a particular service name in the DiameterCharging service's serviceID configuration.- Specified by:
getIDForNamein interfaceServiceIDLookup- Parameters:
name- The service name as it is used e.g. by the promotion features to identify a service- Returns:
- The ID currently mapped to the name or
-1if there is currently no name mapped to the ID.
-
iterator
public java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.Long>> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.Long>>
-
setNewConfiguration
public void setNewConfiguration(long[] ids, java.lang.String[] names)Re-initialize the configuration with a new set of IDs and names.- Parameters:
ids- The list of numeric IDs. Ifnull, 'names' has to benullas well.names- The list of human readable names. Ifnull, 'ids' has to benullas well.- Throws:
java.lang.IllegalArgumentException- If the two lists are of unequal length or just one of them isnull.
-
put
public void put(long id, java.lang.String name)Used by the codec to decode an id/name entry. This approach is faster than having the codec build two lists and then iterating over those lists to populate the maps. Be aware that the inputs are not validated for efficiency reasons since this method is not intended for use other than by codecs.- Parameters:
id-name-
-
getNames
public java.lang.String[] getNames()
- Returns:
- The list of names which was originally used to create this configuration via 'setNewConfiguration'.
-
getIds
public long[] getIds()
- Returns:
- The list of IDs which was originally used to create this configuration via 'setNewConfiguration'.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-