Consistency in data storage often requires pre-processing of user inputs. This project demonstrates the application of the Consumer<T> functional interface. Unlike other functional interfaces, a Consumer is designed to perform an operation on a given argument without returning a result (side-effect only). We implement a text handler that accepts a string, normalizes it by converting it to uppercase, and outputs it to the console. This pattern is widely used in stream processing and reactive programming to handle data elements.
- Standard Tooling: Employed
java.util.function.Consumer<String>to handle text data. - Side-Effect Logic: Implemented a lambda expression
s -> ...that performs an action (printing) instead of returning a value. - Data Normalization: Ensured all processed strings are consistently converted to uppercase using
.toUpperCase(). - Functional Verification: Tested the handler with lowercase input to verify the transformation process.
- Java 8+ (Standard Functional Interfaces, Generics, Consumer)
- Consumer: The standard interface for operations that consume a single input.
- ProcessorLauncherApp: The entry point that defines and executes the data processing logic.
JAVA
Project Structure:
JavaBasics_Task_366/
├── src/
│ └── com/yurii/pavlenko/
│ └── app/
│ └── ProcessorLauncherApp.java
├── LICENSE
├── TASK.md
├── THEORY.md
└── README.md
Code
package com.yurii.pavlenko.app;
import java.util.function.Consumer;
public class ProcessorLauncherApp {
public static void main(String[] args) {
Consumer<String> textHandler = s -> System.out.println(s.toUpperCase());
textHandler.accept("java");
}
}This project is licensed under the MIT License.
Copyright (c) 2026 Yurii Pavlenko
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files...
License: MIT