Package jenkins.model
Class IdStrategy
- All Implemented Interfaces:
ExtensionPoint
,Describable<IdStrategy>
,Comparator<String>
- Direct Known Subclasses:
IdStrategy.CaseInsensitive
,IdStrategy.CaseSensitive
public abstract class IdStrategy
extends AbstractDescribableImpl<IdStrategy>
implements ExtensionPoint, Comparator<String>
The strategy to use for manipulating converting names (e.g. user names, group names, etc) into ids.
- Since:
- 1.566
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The default case insensitiveIdStrategy
static class
A case sensitiveIdStrategy
static class
A case sensitive email addressIdStrategy
.Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionall()
Returns all the registeredIdStrategy
descriptors.abstract int
Compare two IDs and return their sorting order.boolean
This method is used to decide whether aUser.rekey()
operation is required.boolean
Compare two IDs and returntrue
IFF the two ids are the same.filenameOf
(String id) Deprecated.No current use.By default looks for a nested class (conventionally namedDescriptorImpl
) implementingDescriptor
and marked withExtension
.int
hashCode()
idFromFilename
(String filename) Deprecated.Use only for migrating to new format.Converts an ID into a key for use in a Java Map or similar.Deprecated.No current use.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
CASE_INSENSITIVE
The default case insensitive strategy.
-
-
Constructor Details
-
IdStrategy
public IdStrategy()
-
-
Method Details
-
filenameOf
Deprecated.No current use.No longer used. This method is now a no-op but the signature is retained for backward compatibility.- Parameters:
id
- the id.- Returns:
- the name. Must be filesystem safe.
-
legacyFilenameOf
@Deprecated @Restricted(org.kohsuke.accmod.restrictions.ProtectedExternally.class) public String legacyFilenameOf(@NonNull String id) Deprecated.No current use.No longer used. This method is now a no-op but the signature is retained for backward compatibility.- Parameters:
id
- the id- Returns:
- the name
-
idFromFilename
Deprecated.Use only for migrating to new format. After the migration an id is no longer represented by a filename (directory).Converts a filename into the corresponding id. This may contain filesystem unsafe characters.- Parameters:
filename
- the filename.- Returns:
- the corresponding id.
- Since:
- 1.577
-
keyFor
Converts an ID into a key for use in a Java Map or similar. This controls uniqueness of ids and how multiple different ids may map to the same id. For example, all different capitalizations of "Foo" may map to the same value "foo".- Parameters:
id
- the id.- Returns:
- the key.
-
equals
Compare two IDs and returntrue
IFF the two ids are the same. Normally we expect that this should be the same ascompare(String, String)
being equal to0
, however there may be a specific reason for going beyond that, such as sorting id's case insensitively while treating them as case sensitive. Subclasses may want to override this naïve implementation that callscompare(id1, id2) == 0
for a more performant implementation.- Parameters:
id1
- the first id.id2
- the second id.- Returns:
true
if and only if the two ids are the same.
-
compare
Compare two IDs and return their sorting order. Ifequals(String, String)
istrue
then this must return0
butcompare(String, String)
returning0
need not imply thatequals(String, String)
istrue
.- Specified by:
compare
in interfaceComparator<String>
- Parameters:
id1
- the first id.id2
- the second id.- Returns:
- the sorting order of the two IDs.
-
getDescriptor
Description copied from class:AbstractDescribableImpl
By default looks for a nested class (conventionally namedDescriptorImpl
) implementingDescriptor
and marked withExtension
.Gets the descriptor for this instance.
Descriptor
is a singleton for every concreteDescribable
implementation, so ifa.getClass() == b.getClass()
then by defaulta.getDescriptor() == b.getDescriptor()
as well. (In rare cases a single implementation class may be used for instances with distinct descriptors.)- Specified by:
getDescriptor
in interfaceDescribable<IdStrategy>
- Overrides:
getDescriptor
in classAbstractDescribableImpl<IdStrategy>
-
equals
This method is used to decide whether aUser.rekey()
operation is required.- Specified by:
equals
in interfaceComparator<String>
- Overrides:
equals
in classObject
- Parameters:
obj
- the object to compare with.- Returns:
true
if and only ifthis
is the same asobj
.
-
hashCode
public int hashCode() -
toString
-
all
Returns all the registeredIdStrategy
descriptors.
-