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
  • Field Details

    • CASE_INSENSITIVE

      public static IdStrategy CASE_INSENSITIVE
      The default case insensitive strategy.
  • Constructor Details

    • IdStrategy

      public IdStrategy()
  • Method Details

    • 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 return true IFF the two ids are the same. Normally we expect that this should be the same as compare(String, String) being equal to 0, 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 calls compare(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. If equals(String, String) is true then this must return 0 but compare(String, String) returning 0 need not imply that equals(String, String) is true.
      Specified by:
      compare in interface Comparator<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 named DescriptorImpl) implementing Descriptor and marked with Extension.

      Gets the descriptor for this instance.

      Descriptor is a singleton for every concrete Describable implementation, so if a.getClass() == b.getClass() then by default a.getDescriptor() == b.getDescriptor() as well. (In rare cases a single implementation class may be used for instances with distinct descriptors.)

      Specified by:
      getDescriptor in interface Describable<IdStrategy>
      Overrides:
      getDescriptor in class AbstractDescribableImpl<IdStrategy>
    • equals

      public boolean equals(Object obj)
      This method is used to decide whether a User.rekey() operation is required.
      Specified by:
      equals in interface Comparator<String>
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare with.
      Returns:
      true if and only if this is the same as obj.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • all

      Returns all the registered IdStrategy descriptors.