Class FieldId

java.lang.Object
com.atlassian.jira.issue.fields.FieldId

public class FieldId extends Object
Field identifier for both custom and system fields.

Identifiers of system fields are always strings with their human-readable names (e.g. "priority"), while custom fields can be identified by a number (e.g. 10000) or a full textual representation (e.g. "customfield_10000"). This class helps avoid the confusion when handling all these formats.

Methods of creation:

     FieldId.fromCustomFieldId(10000); // a custom field, full ID: "customfield_1000"
     FieldId.fromFullId("description"); // a system field
     FieldId.fromFullId("customfield_1001"); // a custom field with numerial ID 1001
 
Use toFullId() to get a full textual form for all the types of fields:
     FieldId.fromFullId("summary").toFullId() // => "summary"
     FieldId.fromCustomFieldId(10000).toFullId() // => "customfield_10000"
 
  • Method Details

    • fromCustomFieldId

      public static FieldId fromCustomFieldId(long id)
      Creates a custom field ID from a numerical ID
      Throws:
      IllegalArgumentException - when ID invalid input: '<' 0
    • fromFullId

      public static FieldId fromFullId(String id)
      Creates a FieldId from a textual ID in its full format, e.g. "description" or "customfield_10000"
      Throws:
      NullPointerException - when given null
      NumberFormatException - when custom field ID is not a number
    • toString

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

      public String toFullId()
      Returns full textual ID for the field
    • isCustomField

      public boolean isCustomField()
    • isSystemField

      public boolean isSystemField()
    • getCustomFieldId

      public long getCustomFieldId()
      Returns a numerical custom field ID. The caller has to check if it's a custom, not a system, field using isCustomField()
      Throws:
      IllegalStateException - when the ID is of a system field
    • getCustomFieldIdOrNull

      @Nullable public Long getCustomFieldIdOrNull()
      Returns a numerical custom field ID or null when it's a system field.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object