class ThreadFactoryBuilder {

    public ThreadFactoryBuilder withPriority(@Nullable Integer priority) {
        if (priority != null && priority.intValue() < Thread.MIN_PRIORITY) {
            throw new IllegalArgumentException(String.format(
                    "The provided priority %d is below the minimal thread priority %d", priority, Thread.MIN_PRIORITY));
        }

        if (priority != null && priority.intValue() > Thread.MAX_PRIORITY) {
            throw new IllegalArgumentException(String.format(
                    "The provided priority %d is above the maximal thread priority %d", priority, Thread.MAX_PRIORITY));
        }

        this.priority = priority;
        return this;
    }

    private  ThreadFactoryBuilder();

}