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 classIdStrategy.CaseInsensitiveThe default case insensitiveIdStrategystatic classIdStrategy.CaseSensitiveA case sensitiveIdStrategystatic classIdStrategy.CaseSensitiveEmailAddressA case sensitive email addressIdStrategy.-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description static IdStrategyCASE_INSENSITIVEThe 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 registeredIdStrategydescriptors.abstract intcompare(String id1, String id2)Compare two IDs and return their sorting order.booleanequals(Object obj)This method is used to decide whether aUser.rekey()operation is required.booleanequals(String id1, String id2)Compare two IDs and returntrueIFF the two ids are the same.StringfilenameOf(String id)Deprecated.No current use.IdStrategyDescriptorgetDescriptor()By default looks for a nested class (conventionally namedDescriptorImpl) implementingDescriptorand marked withExtension.inthashCode()StringidFromFilename(String filename)Deprecated.Use only for migrating to new format.StringkeyFor(String id)Converts an ID into a key for use in a Java Map or similar.StringlegacyFilenameOf(String id)Deprecated.No current use.StringtoString()-
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 returntrueIFF 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) == 0for a more performant implementation.- Parameters:
id1- the first id.id2- the second id.- Returns:
trueif 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)istruethen this must return0butcompare(String, String)returning0need not imply thatequals(String, String)istrue.- Specified by:
comparein 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:AbstractDescribableImplBy default looks for a nested class (conventionally namedDescriptorImpl) implementingDescriptorand marked withExtension.Gets the descriptor for this instance.
Descriptoris a singleton for every concreteDescribableimplementation, 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:
getDescriptorin interfaceDescribable<IdStrategy>- Overrides:
getDescriptorin classAbstractDescribableImpl<IdStrategy>
-
equals
public boolean equals(Object obj)
This method is used to decide whether aUser.rekey()operation is required.- Specified by:
equalsin interfaceComparator<String>- Overrides:
equalsin classObject- Parameters:
obj- the object to compare with.- Returns:
trueif and only ifthisis the same asobj.
-
all
public static DescriptorExtensionList<IdStrategy,IdStrategyDescriptor> all()
Returns all the registeredIdStrategydescriptors.
-
-