Example usage for org.eclipse.jgit.attributes AttributesNode getRules

List of usage examples for org.eclipse.jgit.attributes AttributesNode getRules

Introduction

In this page you can find the example usage for org.eclipse.jgit.attributes AttributesNode getRules.

Prototype

public List<AttributesRule> getRules() 

Source Link

Document

Getter for the field rules.

Usage

From source file:com.diffplug.gradle.spotless.GitAttributesLineEndingPolicy.java

License:Apache License

/** Parses a list of rules from the given file, returning an empty list if the file doesn't exist. */
private static List<AttributesRule> parseRules(File file) {
    if (file.exists() && file.isFile()) {
        try (InputStream stream = new FileInputStream(file)) {
            AttributesNode parsed = new AttributesNode();
            parsed.parse(stream);/* w w w. ja  va 2 s .c om*/
            return parsed.getRules();
        } catch (IOException e) {
            // no need to crash the whole plugin
            System.err.println("Problem parsing " + file.getAbsolutePath());
            e.printStackTrace();
        }
    }
    return Collections.emptyList();
}

From source file:com.diffplug.spotless.extra.GitAttributesLineEndings.java

License:Apache License

/** Parses a list of rules from the given file, returning an empty list if the file doesn't exist. */
private static List<AttributesRule> parseRules(@Nullable File file) {
    if (file != null && file.exists() && file.isFile()) {
        try (InputStream stream = new FileInputStream(file)) {
            AttributesNode parsed = new AttributesNode();
            parsed.parse(stream);/*w  w w.  ja  v a2  s .  c  o m*/
            return parsed.getRules();
        } catch (IOException e) {
            // no need to crash the whole plugin
            System.err.println("Problem parsing " + file.getAbsolutePath());
            e.printStackTrace();
        }
    }
    return Collections.emptyList();
}