Class AttributesRule


  • public class AttributesRule
    extends java.lang.Object
    A single attributes rule corresponding to one line in a .gitattributes file. Inspiration from: FastIgnoreRule
    Since:
    3.7
    • Constructor Summary

      Constructors 
      Constructor Description
      AttributesRule​(java.lang.String pattern, java.lang.String attributes)
      Create a new attribute rule with the given pattern.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean dirOnly()  
      java.util.List<Attribute> getAttributes()
      Returns the attributes.
      java.lang.String getPattern()  
      boolean isMatch​(java.lang.String relativeTarget, boolean isDirectory)
      Returns true if a match was made.
      boolean isNameOnly()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AttributesRule

        public AttributesRule​(java.lang.String pattern,
                              java.lang.String attributes)
        Create a new attribute rule with the given pattern. Assumes that the pattern is already trimmed.
        Parameters:
        pattern - Base pattern for the attributes rule. This pattern will be parsed to generate rule parameters. It can not be null.
        attributes - the rule attributes. This string will be parsed to read the attributes.
    • Method Detail

      • dirOnly

        public boolean dirOnly()
        Returns:
        True if the pattern should match directories only
      • getAttributes

        public java.util.List<Attribute> getAttributes()
        Returns the attributes.
        Returns:
        an unmodifiable list of attributes (never returns null)
      • isNameOnly

        public boolean isNameOnly()
        Returns:
        true if the pattern is just a file name and not a path
      • getPattern

        public java.lang.String getPattern()
        Returns:
        The blob pattern to be used as a matcher (never returns null)
      • isMatch

        public boolean isMatch​(java.lang.String relativeTarget,
                               boolean isDirectory)
        Returns true if a match was made.
        Parameters:
        relativeTarget - Name pattern of the file, relative to the base directory of this rule
        isDirectory - Whether the target file is a directory or not
        Returns:
        True if a match was made.