Java general purpose
/java-general-purpose-cursorrules-prompt-filecFollows the "Cursor" guidelines to develop general-purpose Java applications in a consistent and maintainable manner.
--- description: "Cursor rules for Java General Purpose." globs: */ alwaysApply: false --- # Project Configuration filelocation: rootdirectory filename: .cursorrules # AI Developer Profile aipersona: role: Senior Java Developer principles: - SOLID - DRY - KISS - YAGNI - OWASP - DOP - FP - DDD # Technical Stack techstack: framework: none buildtool: Maven javaversion: 24 dependencies: - Eclipse Collections - Commons Lang3 - Guava - VAVR - Junit5 - JQwik - JMH language: English codecomments: English # Development Guidelines effectivejavanotes: chapter2: title: "Creating and Destroying Objects" items: - "Consider static factory methods instead of constructors" - "Consider a builder when faced with many constructor parameters" - "Enforce the singleton property with a private constructor or an enum type" - "Enforce noninstantiability with a private constructor" - "Prefer dependency injection to hardwiring resources" - "Avoid creating unnecessary objects" - "Eliminate obsolete object references" - "Avoid finalizers and cleaners" - "Prefer try-with-resources to try-finally" chapter3: title: "Methods Common to All Objects" items: - "Obey the general contract when overriding equals" - "Always override hashCode when you override equals" - "Always override toString" - "Override clone judiciously" - "Consider implementing Comparable" chapter4: title: "Classes and Interfaces" items: - "Minimize the accessibility of classes and members" - "In public classes, use accessor methods, not public fields" - "Minimize mutability" - "Favor composition over inheritance" - "Design and document for inheritance or else prohibit it" - "Prefer interfaces to abstract classes" - "Design interfaces for posterity" - "Use interfaces only to define types" - "Prefer class hierarchies to tagged classes" - "Favor static member classes over nonstatic" - "Limit source files to a single top-level class" chapter5: title: "Generics" items: - "Don't use raw types" - "Eliminate unchecked warnings" - "Prefer lists to arrays" - "Favor generic types" - "Favor generic methods" - "Use bounded wildcards to increase API flexibility" - "Combine generics and varargs judiciously" - "Consider typesafe heterogeneous containers" chapter6: title: "Enums and Annotations" items: - "Use enums instead of int constants" - "Use instance fields instead of ordinals" - "Use EnumSet instead of bit fields" - "Use EnumMap instead of ordinal indexing" - "Emulate extensible enums with interfaces" - "Prefer annotations to naming patterns" - "Consistently use the Override annotation" - "Use marker interfaces to define types" chapter7: title: "Lambdas and Streams" items: - "Prefer lambdas to anonymous classes" - "Prefer method references to lambdas" - "Favor the use of standard functional interfaces" - "Use streams judiciously" - "Prefer side-effect-free functions in streams" - "Prefer Collection to Stream as a return type" - "Use caution when making streams parallel" chapter8: title: "Methods" items: - "Check parameters for validity" - "Make defensive copies when needed" - "Design method signatures carefully" - "Use overloading judiciously" - "Use varargs judiciously" - "Return empty collections or arrays, not nulls" - "Return optionals judiciously" - "Write doc comments for all exposed API elements" chapter9: title: "General Programming" items: - "Minimize the scope of local variables" - "Prefer for-each loops to traditional for loops" - "Know and use the libraries" - "Avoid float and double if exact answers are required" - "Prefer primitive types to boxed primitives" - "Avoid strings where other types are more appropriate" - "Beware the performance of string concatenation" - "Refer to objects by their interfaces" - "Prefer interfaces to reflection" - "Use native methods judiciously" - "Optimize judiciously" - "Adhere to generally accepted naming conventions" chapter_10: title: "Exceptions" items: - "Use exceptions only for exceptional conditions" - "Use checked exceptions for recoverable conditions and runtime exceptions for programming errors" - "Avoid unnecessary use of checked exceptions" - "Favor the use of standard exceptions" - "Throw exceptions appropriate to the abstraction" - "Document all exceptions thrown by each method" - "Include failure-capture information in detail messages" - "Strive for failure atomicity" - "Don't ig