EnterpriseQualityCoding/FizzBuzzEnterpriseEdition · error · UnsupportedOperationException
com.seriouscompany.business.java.fizzbuzz.packagenamingpacka
Error message
com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.printers.IntegerIntegerPrinter.print()
What it means
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.
Source
Thrown at src/main/java/com/seriouscompany/business/java/fizzbuzz/packagenamingpackage/impl/printers/IntegerIntegerPrinter.java:53
* @param theInteger
*/
public void printInteger(final int theInteger) {
final IntegerStringReturner myIntegerStringReturner =
this._integerIntegerStringReturnerFactory.createIntegerStringReturner();
final String myIntegerString = myIntegerStringReturner.getIntegerReturnString(theInteger);
final FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter myOutputAdapter =
new FizzBuzzOutputStrategyToFizzBuzzExceptionSafeOutputStrategyAdapter(
this._systemOutFizzBuzzOutputStrategyFactory.createOutputStrategy());
myOutputAdapter.output(myIntegerString);
}
/**
* @return void
*/
@Override
public void print() {
throw new UnsupportedOperationException(
com.seriouscompany.business.java.fizzbuzz.packagenamingpackage.impl.Constants.COM_SERIOUSCOMPANY_BUSINESS_JAVA_FIZZBUZZ_PACKAGENAMINGPACKAGE_IMPL_PRINTERS_INTEGER_INTEGER_PRINTER_PRINT);
}
/**
* @param value
*/
@Override
public void printValue(final Object value) {
this.printInteger((Integer) value);
}
}
View on GitHub (pinned to 4922c077c0)
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.
Example fix
// before IntegerIntegerPrinter printer = new IntegerIntegerPrinter(...); printer.print(); // throws UnsupportedOperationException // after IntegerIntegerPrinter printer = new IntegerIntegerPrinter(...); printer.printValue(42); // prints the integer via the exception-safe output adapter
Defensive patterns
Strategy: type-guard
Validate before calling
// Before dispatching over mixed printers, ensure the printer supports no-arg print()
if (printer instanceof IntegerIntegerPrinter) {
printer.printValue(Integer.valueOf(42));
} else {
printer.print();
} Type guard
// Narrow to the value-carrying contract before calling
private static boolean requiresValue(final Object printer) {
return printer instanceof IntegerIntegerPrinter;
}
if (requiresValue(printer)) {
((IntegerIntegerPrinter) printer).printValue(value);
} else {
((Printer) printer).print();
} Try / catch
// When dispatch code is not under your control
try {
printer.print();
} catch (final UnsupportedOperationException e) {
if (!e.getMessage().contains("IntegerIntegerPrinter.print")) {
throw e; // a different, real unsupported-operation failure
}
logger.debug("Printer requires an explicit value; falling back to printValue");
printer.printValue(currentValue);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of EnterpriseQualityCoding/FizzBuzzEnterpriseEdition@4922c077c0 (2026-08-14).
Data as JSON: /api/errors/03edb202d54580c9.
Report an issue: GitHub.