{"record":{"id":"03edb202d54580c9","repo":"EnterpriseQualityCoding/FizzBuzzEnterpriseEdition","slug":"com-seriouscompany-business-java-fizzbuzz-packagen","errorCode":null,"errorMessage":"com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.printers.IntegerIntegerPrinter.print()","messagePattern":"com\\.seriouscompany\\.business\\.java\\.fizzbuzz\\.packagenamingpackage\\.impl\\.printers\\.IntegerIntegerPrinter\\.print\\(\\)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/printers/IntegerIntegerPrinter.java","lineNumber":53,"sourceCode":"\t * @param theInteger\n\t */\n\tpublic void printInteger(final int theInteger) {\n\t\tfinal IntegerStringReturner myIntegerStringReturner =\n\t\t\t\tthis._integerIntegerStringReturnerFactory.createIntegerStringReturner();\n\t\tfinal String myIntegerString = myIntegerStringReturner.getIntegerReturnString(theInteger);\n\t\tfinal FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter myOutputAdapter =\n\t\t\t\tnew FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter(\n\t\t\t\t\t\tthis._systemOutFizzBuzzOutputStrategyFactory.createOutputStrategy());\n\n\t\tmyOutputAdapter.output(myIntegerString);\n\t}\n\n\t/**\n\t * @return void\n\t */\n\t@Override\n\tpublic void print() {\n\t\tthrow new UnsupportedOperationException(\n\t\t\t\tcom.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.Constants.COM_SERIOUSCOMPANY_BUSINESS_JAVA_FIZZBUZZ_PACKAGENAMINGPACKAGE_IMPL_PRINTERS_INTEGER_INTEGER_PRINTER_PRINT);\n\t}\n\n\t/**\n\t * @param value\n\t */\n\t@Override\n\tpublic void printValue(final Object value) {\n\t\tthis.printInteger((Integer) value);\n\t}\n\n}\n","sourceCodeStart":35,"sourceCodeEnd":66,"githubUrl":"https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition/blob/4922c077c07a3744ae67ee8a932786f15bf57411/src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/printers/IntegerIntegerPrinter.java#L35-L66","documentation":"IntegerIntegerPrinter implements the printer interface but deliberately supports only printValue(Object)/printInteger(Integer); the no-argument print() override unconditionally throws UnsupportedOperationException with the fully-qualified constant COM_SERIOUSCOMPANY_BUSINESS_JAVA_FIZZBUZZ_PACKAGENAMINGPACKAGE_IMPL_PRINTERS_INTEGER_INTEGER_PRINTER_PRINT (whose value is the class-and-method name shown in the message). This is the codebase's pattern for 'this operation is not part of this implementation's contract' — the printer needs a value supplied; it cannot print anything on its own.","triggerScenarios":"Calling new IntegerIntegerPrinter(...).print() (zero-arg overload) directly, or passing an IntegerIntegerPrinter to code that dispatches via the no-arg print() method of the printer interface instead of printValue(value). The exception is thrown on every such call — there is no state that makes it succeed.","commonSituations":"Polymorphic code that holds a List<...Printer> and uniformly invokes print() over mixed implementations (SystemOutPrinter vs IntegerIntegerPrinter), so the Integer variant blows up. Also: refactoring that renames printValue to print, or new contributors assuming print() is a valid 'print the last/current value' call. The message being a fully-qualified constant rather than a human sentence often confuses log searches until you realize the constant's value IS the method signature.","solutions":["Call printValue(value) (or printInteger((Integer) value)) instead of print() — the class only implements the value-carrying contract.","If generic code must call print(), route it through printValue: change the dispatch site to printer.printValue(someInteger) or wrap the call so the value is passed.","If you own the interface, remove the no-arg print() from it, or give it a default implementation that throws only for genuinely unsupported cases, so implementations don't hand-roll unsupported stubs.","If you truly need a no-arg integer print, add state (a stored Integer) and implement print() to delegate to printInteger(storedValue) rather than throwing."],"exampleFix":"// before\nIntegerIntegerPrinter printer = new IntegerIntegerPrinter(...);\nprinter.print(); // throws UnsupportedOperationException\n\n// after\nIntegerIntegerPrinter printer = new IntegerIntegerPrinter(...);\nprinter.printValue(42); // prints the integer via the exception-safe output adapter","handlingStrategy":"type-guard","validationCode":"// Before dispatching over mixed printers, ensure the printer supports no-arg print()\nif (printer instanceof IntegerIntegerPrinter) {\n    printer.printValue(Integer.valueOf(42));\n} else {\n    printer.print();\n}","typeGuard":"// Narrow to the value-carrying contract before calling\nprivate static boolean requiresValue(final Object printer) {\n    return printer instanceof IntegerIntegerPrinter;\n}\n\nif (requiresValue(printer)) {\n    ((IntegerIntegerPrinter) printer).printValue(value);\n} else {\n    ((Printer) printer).print();\n}","tryCatchPattern":"// When dispatch code is not under your control\ntry {\n    printer.print();\n} catch (final UnsupportedOperationException e) {\n    if (!e.getMessage().contains(\"IntegerIntegerPrinter.print\")) {\n        throw e; // a different, real unsupported-operation failure\n    }\n    logger.debug(\"Printer requires an explicit value; falling back to printValue\");\n    printer.printValue(currentValue);\n}","preventionTips":["Prefer the value-carrying API (printValue/printInteger) for printers that need input; treat no-arg print() as unsupported by default in this codebase.","When iterating heterogeneous printers, dispatch on the type you hold instead of assuming a uniform no-arg contract.","Check the source of any printer implementation before calling an interface method — this codebase marks unsupported ops with unconditional throws, not with abstract-method errors.","Search for UnsupportedOperationException constants in Constants.java to learn which methods are decorative before integrating."],"tags":["java","unsupported-operation","api-misuse","fizzbuzz-enterprise","interface-contract"],"backgroundTag":null,"analyzedSha":"4922c077c07a3744ae67ee8a932786f15bf57411","analyzedAt":"2026-08-14T10:51:26.690Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}