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 boolean
equals(java.lang.Object o)
long
getIDForName(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.String
getServiceNameForID(long id)
Lookup the name which is currently mapped to a particular service ID in the DiameterCharging service's service ID configuration.int
hashCode()
java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.Long>>
iterator()
void
put(long id, java.lang.String name)
Used by the codec to decode an id/name entry.void
setNewConfiguration(long[] ids, java.lang.String[] names)
Re-initialize the configuration with a new set of IDs and names.java.lang.String
toString()
-
-
-
Method Detail
-
getServiceNameForID
public java.lang.String getServiceNameForID(long id)
Description copied from interface:ServiceIDLookup
Lookup the name which is currently mapped to a particular service ID in the DiameterCharging service's service ID configuration.- Specified by:
getServiceNameForID
in interfaceServiceIDLookup
- Parameters:
id
- The service ID as it appears in the MSCC's 'serviceIDs' AVP- Returns:
- The name currently mapped to the ID or
null
if there is currently no name mapped to the ID.
-
getIDForName
public long getIDForName(java.lang.String name)
Description copied from interface:ServiceIDLookup
Lookup the numerical identifier which is currently mapped to a particular service name in the DiameterCharging service's serviceID configuration.- Specified by:
getIDForName
in 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
-1
if 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:
iterator
in 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 benull
as well.names
- The list of human readable names. Ifnull
, 'ids' has to benull
as 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:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-