Package jenkins.model
Class IdStrategy
- java.lang.Object
-
- hudson.model.AbstractDescribableImpl<IdStrategy>
-
- jenkins.model.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
Nested Classes Modifier and Type Class Description static class
IdStrategy.CaseInsensitive
The default case insensitiveIdStrategy
static class
IdStrategy.CaseSensitive
A case sensitiveIdStrategy
static class
IdStrategy.CaseSensitiveEmailAddress
A case sensitive email addressIdStrategy
.-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description static IdStrategy
CASE_INSENSITIVE
The default case insensitive strategy.
-
Constructor Summary
Constructors Constructor Description IdStrategy()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static DescriptorExtensionList<IdStrategy,IdStrategyDescriptor>
all()
Returns all the registeredIdStrategy
descriptors.abstract int
compare(String id1, String id2)
Compare two IDs and return their sorting order.boolean
equals(Object obj)
This method is used to decide whether aUser.rekey()
operation is required.boolean
equals(String id1, String id2)
Compare two IDs and returntrue
IFF the two ids are the same.String
filenameOf(String id)
Deprecated.No current use.IdStrategyDescriptor
getDescriptor()
By default looks for a nested class (conventionally namedDescriptorImpl
) implementingDescriptor
and marked withExtension
.int
hashCode()
String
idFromFilename(String filename)
Deprecated.Use only for migrating to new format.String
keyFor(String id)
Converts an ID into a key for use in a Java Map or similar.String
legacyFilenameOf(String id)
Deprecated.No current use.String
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 Detail
-
CASE_INSENSITIVE
public static IdStrategy CASE_INSENSITIVE
The default case insensitive strategy.
-
-
Method Detail
-
filenameOf
@Deprecated public String filenameOf(@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. 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 public String idFromFilename(@NonNull String filename)
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
@NonNull public String keyFor(@NonNull String id)
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
public boolean equals(@NonNull String id1, @NonNull String id2)
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
public abstract int compare(@NonNull String id1, @NonNull String id2)
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
public IdStrategyDescriptor 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
public boolean equals(Object obj)
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
.
-
all
public static DescriptorExtensionList<IdStrategy,IdStrategyDescriptor> all()
Returns all the registeredIdStrategy
descriptors.
-
-