class

Analyzer::Java::SpringDataRest

Inherits Analyzer::Java::JavaEngine < Analyzer < FileHelper < Reference < Object

Spring Data REST exports every public repository interface as a CRUD + search API with no controller code. Routes come from the repository types: @RepositoryRestResource(path=) only renames them.

Constants

BASE_LEVELS = {"Repository" => 0, "ListPagingAndSortingRepository" => 1, "CrudRepository" => 2, "ListCrudRepository" => 2, "PagingAndSortingRepository" => 2, "JpaRepository" => 2, "MongoRepository" => 2, "CassandraRepository" => 2, "Neo4jRepository" => 2, "KeyValueRepository" => 2, "CouchbaseRepository" => 2, "ElasticsearchRepository" => 2}

Spring Data base interfaces, mapped to what they export: 2 = full CRUD, 1 = collection GET only, 0 = only what the interface declares. PagingAndSortingRepository extends CrudRepository up to Spring Data 2.x and is counted as CRUD; on 3.x it is paging-only, which over-reports the write verbs of a repository that extends nothing else.

BUILD_FILES = ["pom.xml", "build.gradle", "build.gradle.kts"] of ::String
CRUD_METHODS = Set {"findAll", "findById", "findAllById", "existsById", "count", "save", "saveAll", "saveAndFlush", "saveAllAndFlush", "delete", "deleteById", "deleteAll", "deleteAllById", "deleteAllInBatch", "deleteAllByIdInBatch", "flush", "getById", "getOne", "getReferenceById"}
DELETE_METHODS = Set {"delete", "deleteById"}

Data REST exports DELETE through either method, so hiding it takes both.

INTERFACE_GATE = /\binterface\s+\w+[^{]*\bextends\b/
MAX_BASE_DEPTH = 8
PLURAL_RULES = [category(["fish", "ois", "sheep", "deer", "pox", "itis", "bison", "flounder", "pliers", "bream", "gallows", "proceedings", "breeches", "graffiti", "rabies", "britches", "headquarters", "salmon", "carp", "herpes", "scissors", "chassis", "high-jinks", "sea-bass", "clippers", "homework", "series", "cod", "innings", "shears", "contretemps", "jackanapes", "species", "corps", "mackerel", "swine", "debris", "measles", "trout", "diabetes", "mews", "tuna", "djinn", "mumps", "whiting", "eland", "news", "wildebeest", "elk", "pincers", "sugar"] of ::String, "", ""), {/(c)hild\z/i, "\\1hildren"}, {/(e)phemeris\z/i, "\\1phemerides"}, {/(m)ongoose\z/i, "\\1ongoose"}, {/(m)ythos\z/i, "\\1ythoi"}, {/(s)oliloquy\z/i, "\\1oliloquies"}, {/(t)rilby\z/i, "\\1rilbys"}, {/(g)enus\z/i, "\\1enera"}, {/(q)uiz\z/i, "\\1uizzes"}, {/(b)eef\z/i, "\\1eefs"}, {/(b)rother\z/i, "\\1rothers"}, {/(c)ow\z/i, "\\1ows"}, {/(g)enie\z/i, "\\1enies"}, {/(m)oney\z/i, "\\1oneys"}, {/(o)ctopus\z/i, "\\1ctopuses"}, {/(o)pus\z/i, "\\1puses"}, category(["human"] of ::String, "", "s"), {/man\z/i, "men"}, {/([lm])ouse\z/i, "\\1ice"}, {/tooth\z/i, "teeth"}, {/goose\z/i, "geese"}, {/foot\z/i, "feet"}, {/zoon\z/i, "zoa"}, {/([csx])is\z/i, "\\1es"}, category(["codex", "murex", "silex"] of ::String, "ex", "ices"), category(["radix", "helix"] of ::String, "ix", "ices"), category(["bacterium", "agendum", "desideratum", "erratum", "stratum", "datum", "ovum", "extremum", "candelabrum"] of ::String, "um", "a"), category(["criterion", "perihelion", "aphelion", "phenomenon", "prolegomenon", "noumenon", "organon", "asyndeton", "hyperbaton"] of ::String, "on", "a"), category(["alumna", "alga", "vertebra", "persona"] of ::String, "a", "ae"), category(["alumnus", "alveolus", "bacillus", "bronchus", "locus", "nucleus", "stimulus", "meniscus", "thesaurus"] of ::String, "us", "i"), {/([cs]h|[zx])\z/i, "\\1es"}, category(["acropolis", "chaos", "lens", "aegis", "cosmos", "mantis", "alias", "dais", "marquis", "asbestos", "digitalis", "metropolis", "atlas", "epidermis", "pathos", "bathos", "ethos", "pelvis", "bias", "gas", "polis", "caddis", "glottis", "rhinoceros", "cannabis", "sassafras", "canvas", "ibis", "trellis", "iris", "clitoris", "apparatus", "impetus", "prospectus", "cantus", "nexus", "sinus", "coitus", "plexus", "status", "hiatus"] of ::String, "", "es"), {/(us)\z/i, "\\1es"}, category(["anathema", "enema", "oedema", "bema", "enigma", "sarcoma", "carcinoma", "gumma", "schema", "charisma", "lemma", "soma", "diploma", "lymphoma", "stigma", "dogma", "magma", "stoma", "drama", "melisma", "trauma", "edema", "miasma"] of ::String, "", "s"), {/ss\z/i, "sses"}, {/([aeo]l)f\z/i, "\\1ves"}, {/([^d]ea)f\z/i, "\\1ves"}, {/(ar)f\z/i, "\\1ves"}, {/([nlw]i)fe\z/i, "\\1ves"}, {/([aeiou]y)\z/i, "\\1s"}, {/y\z/i, "ies"}, category(["solo", "soprano", "basso", "alto", "contralto", "tempo", "piano", "virtuoso", "albino", "archipelago", "armadillo", "commando", "crescendo", "fiasco", "ditto", "dynamo", "embryo", "ghetto", "guano", "inferno", "jumbo", "lumbago", "magneto", "manifesto", "medico", "octavo", "photo", "pro", "quarto", "canto", "lingo", "generalissimo", "stylo", "rhino", "casino", "auto", "macro", "zero", "todo"] of ::String, "o", "os"), {/([aeiou]o)\z/i, "\\1s"}, {/o\z/i, "oes"}, {/(ul)um\z/i, "\\1a"}, {/s\z/i, "ses"}]

Evo Inflector 1.3's anglicized English.plural, which Spring Data REST derives the default path with: every rule is a case-insensitive suffix match and the first one that matches wins. person is not irregular there, so Person maps to /persons.

QUERY_METHOD_RE = /^(?:find|read|get|query|search|stream|count|exists|delete|remove)[A-Z]/
SOURCE_MARKER = Regex.union("org.springframework.data.rest")

Class methods

category(words : Array(String), singular : String, plural : String) : Tuple(Regex, String)

{pattern, replacement} turning each of words (all ending in singular) into its plural.

Source
pluralize(word : String) : String
Source
tech_name
Source

Instance methods

analyze
Source
tech

Instance-side view of the same declaration. The per-file rescues live on this base class, which has no way to name the analyzer that is running inside them, so a skipped file could not be attributed to a tech. Deriving it from analyzer_for keeps the name written exactly once.

Source

Nested types