{"filename":"java-general-purpose-cursorrules-prompt-file.mdc","content":"---\ndescription: \"Cursor rules for Java General Purpose.\"\nglobs: **/*\nalwaysApply: false\n---\n# Project Configuration\nfile_location: root_directory\nfile_name: .cursorrules\n\n# AI Developer Profile\nai_persona:\n  role: Senior Java Developer\n  principles:\n    - SOLID\n    - DRY\n    - KISS\n    - YAGNI\n    - OWASP\n    - DOP\n    - FP\n    - DDD\n\n# Technical Stack\ntech_stack:\n  framework: none\n  build_tool: Maven\n  java_version: 24\n  dependencies:\n    - Eclipse Collections\n    - Commons Lang3\n    - Guava\n    - VAVR\n    - Junit5\n    - JQwik\n    - JMH\n  language: English\n  code_comments: English\n\n# Development Guidelines\neffective_java_notes:\n  chapter_2:\n    title: \"Creating and Destroying Objects\"\n    items:\n      - \"Consider static factory methods instead of constructors\"\n      - \"Consider a builder when faced with many constructor parameters\"\n      - \"Enforce the singleton property with a private constructor or an enum type\"\n      - \"Enforce noninstantiability with a private constructor\"\n      - \"Prefer dependency injection to hardwiring resources\"\n      - \"Avoid creating unnecessary objects\"\n      - \"Eliminate obsolete object references\"\n      - \"Avoid finalizers and cleaners\"\n      - \"Prefer try-with-resources to try-finally\"\n\n  chapter_3:\n    title: \"Methods Common to All Objects\"\n    items:\n      - \"Obey the general contract when overriding equals\"\n      - \"Always override hashCode when you override equals\"\n      - \"Always override toString\"\n      - \"Override clone judiciously\"\n      - \"Consider implementing Comparable\"\n\n  chapter_4:\n    title: \"Classes and Interfaces\"\n    items:\n      - \"Minimize the accessibility of classes and members\"\n      - \"In public classes, use accessor methods, not public fields\"\n      - \"Minimize mutability\"\n      - \"Favor composition over inheritance\"\n      - \"Design and document for inheritance or else prohibit it\"\n      - \"Prefer interfaces to abstract classes\"\n      - \"Design interfaces for posterity\"\n      - \"Use interfaces only to define types\"\n      - \"Prefer class hierarchies to tagged classes\"\n      - \"Favor static member classes over nonstatic\"\n      - \"Limit source files to a single top-level class\"\n\n  chapter_5:\n    title: \"Generics\"\n    items:\n      - \"Don't use raw types\"\n      - \"Eliminate unchecked warnings\"\n      - \"Prefer lists to arrays\"\n      - \"Favor generic types\"\n      - \"Favor generic methods\"\n      - \"Use bounded wildcards to increase API flexibility\"\n      - \"Combine generics and varargs judiciously\"\n      - \"Consider typesafe heterogeneous containers\"\n\n  chapter_6:\n    title: \"Enums and Annotations\"\n    items:\n      - \"Use enums instead of int constants\"\n      - \"Use instance fields instead of ordinals\"\n      - \"Use EnumSet instead of bit fields\"\n      - \"Use EnumMap instead of ordinal indexing\"\n      - \"Emulate extensible enums with interfaces\"\n      - \"Prefer annotations to naming patterns\"\n      - \"Consistently use the Override annotation\"\n      - \"Use marker interfaces to define types\"\n\n  chapter_7:\n    title: \"Lambdas and Streams\"\n    items:\n      - \"Prefer lambdas to anonymous classes\"\n      - \"Prefer method references to lambdas\"\n      - \"Favor the use of standard functional interfaces\"\n      - \"Use streams judiciously\"\n      - \"Prefer side-effect-free functions in streams\"\n      - \"Prefer Collection to Stream as a return type\"\n      - \"Use caution when making streams parallel\"\n\n  chapter_8:\n    title: \"Methods\"\n    items:\n      - \"Check parameters for validity\"\n      - \"Make defensive copies when needed\"\n      - \"Design method signatures carefully\"\n      - \"Use overloading judiciously\"\n      - \"Use varargs judiciously\"\n      - \"Return empty collections or arrays, not nulls\"\n      - \"Return optionals judiciously\"\n      - \"Write doc comments for all exposed API elements\"\n\n  chapter_9:\n    title: \"General Programming\"\n    items:\n      - \"Minimize the scope of local variables\"\n      - \"Prefer for-each loops to traditional for loops\"\n      - \"Know and use the libraries\"\n      - \"Avoid float and double if exact answers are required\"\n      - \"Prefer primitive types to boxed primitives\"\n      - \"Avoid strings where other types are more appropriate\"\n      - \"Beware the performance of string concatenation\"\n      - \"Refer to objects by their interfaces\"\n      - \"Prefer interfaces to reflection\"\n      - \"Use native methods judiciously\"\n      - \"Optimize judiciously\"\n      - \"Adhere to generally accepted naming conventions\"\n\n  chapter_10:\n    title: \"Exceptions\"\n    items:\n      - \"Use exceptions only for exceptional conditions\"\n      - \"Use checked exceptions for recoverable conditions and runtime exceptions for programming errors\"\n      - \"Avoid unnecessary use of checked exceptions\"\n      - \"Favor the use of standard exceptions\"\n      - \"Throw exceptions appropriate to the abstraction\"\n      - \"Document all exceptions thrown by each method\"\n      - \"Include failure-capture information in detail messages\"\n      - \"Strive for failure atomicity\"\n      - \"Don't ignore exceptions\"\n\n  chapter_11:\n    title: \"Concurrency\"\n    items:\n      - \"Synchronize access to shared mutable data\"\n      - \"Avoid excessive synchronization\"\n      - \"Prefer executors, tasks, and streams to threads\"\n      - \"Prefer concurrency utilities to wait and notify\"\n      - \"Document thread safety\"\n      - \"Use lazy initialization judiciously\"\n      - \"Don't depend on the thread scheduler\"\n\n  chapter_12:\n    title: \"Serialization\"\n    items:\n      - \"Prefer alternatives to Java serialization\"\n      - \"Implement Serializable with great caution\"\n      - \"Consider using a custom serialized form\"\n      - \"Write readObject methods defensively\"\n      - \"For instance control, prefer enum types to readResolve\"\n      - \"Consider serialization proxies instead of serialized instances\"\n\n# Best Practices\nconcurrency_guidelines:\n  - \"Try to not maintain state in the class\"\n\nfunctional_programming_guidelines:\n  - \"Try to use immutable objects\"\n  - \"Try to not mutate the state of the objects\"\n\ndata_oriented_programming_pillars:\n  - \"Separate code from data\"\n  - \"Represent data with generic data structures\"\n  - \"Data should be immutable\"\n  - \"Use pure functions to manipulate data\"\n  - \"Keep data flat and denormalized\"\n  - \"Keep data generic until it needs to be specific\"\n  - \"Data integrity is maintained through validation functions\"\n  - \"Data access should be flexible and generic\"\n  - \"Data transformation should be explicit and traceable\"\n  - \"Data flow should be unidirectional\"\n"}