Package me.josephsf.jobportaljosephsfeir.util
package me.josephsf.jobportaljosephsfeir.util
Provides utility classes for the Job Portal application.
This package contains utility classes that provide helper methods and constants used throughout the application. These utilities encapsulate common functionality related to string manipulation, date operations, and application-wide constants.
Key components in this package:
Constants- Defines application-wide constants, including enum-like values for status codes, roles, error messages, and configuration valuesDateUtil- Provides helper methods for date formatting, parsing, comparison, and manipulationStringUtil- Offers string validation, formatting, and transformation utilities
These utility classes follow these design principles:
- All classes are final with private constructors to prevent instantiation
- All methods are static and do not maintain state
- Null-safety is ensured throughout with appropriate null checks
- Methods are designed to be reusable across different parts of the application
- Consistent naming conventions are used for similar types of operations
Example usage of DateUtil:
// Format a date for display
LocalDate applicationDate = job.getPostedDate().toLocalDate();
String formattedDate = DateUtil.formatDate(applicationDate);
// Check if an application deadline has passed
if (DateUtil.isPast(job.getDeadline())) {
throw new BadRequestException("Job application deadline has passed");
}
Example usage of StringUtil:
// Validate an email address
if (!StringUtil.isValidEmail(userDto.getEmail())) {
throw new BadRequestException("Invalid email format");
}
// Create a URL-friendly slug for a job title
String jobSlug = StringUtil.slugify(jobDto.getTitle());
Example usage of Constants:
// Check application status
if (application.getStatus().equals(Constants.APPLICATION_STATUS_ACCEPTED)) {
// Send congratulatory email to candidate
}
// Use standard error message
throw new ResourceNotFoundException(Constants.JOB_NOT_FOUND);
- Since:
- 2025-05-15
-
ClassesClassDescriptionConstants class for the Job Portal application.Utility class for date and time operations in the Job Portal system.Utility class for string manipulation and validation in the Job Portal system.