class Utils {

    public static String validateServiceOption(EnumSet<ServiceOption> options,
            ServiceOption option) {
        if (!options.contains(option)) {
            return null;
        }

        EnumSet<ServiceOption> reqs = EnumSet.noneOf(ServiceOption.class);
        EnumSet<ServiceOption> antiReqs = EnumSet.noneOf(ServiceOption.class);
        switch (option) {
        case CONCURRENT_UPDATE_HANDLING:
            antiReqs = EnumSet.of(ServiceOption.OWNER_SELECTION,
                    ServiceOption.STRICT_UPDATE_CHECKING);
            break;
        case OWNER_SELECTION:
            antiReqs = EnumSet.of(ServiceOption.CONCURRENT_UPDATE_HANDLING);
            break;
        case STRICT_UPDATE_CHECKING:
            antiReqs = EnumSet.of(ServiceOption.CONCURRENT_UPDATE_HANDLING);
            break;
        case URI_NAMESPACE_OWNER:
            antiReqs = EnumSet.of(ServiceOption.PERSISTENCE, ServiceOption.REPLICATION);
            break;
        case PERIODIC_MAINTENANCE:
            antiReqs = EnumSet.of(ServiceOption.IMMUTABLE);
            break;
        case PERSISTENCE:
            break;
        case REPLICATION:
            break;
        case DOCUMENT_OWNER:
            break;
        case IDEMPOTENT_POST:
            break;
        case CORE:
            break;
        case FACTORY:
            break;
        case FACTORY_ITEM:
            break;
        case HTML_USER_INTERFACE:
            break;
        case INSTRUMENTATION:
            antiReqs = EnumSet.of(ServiceOption.IMMUTABLE);
            break;
        case LIFO_QUEUE:
            break;
        case NONE:
            break;
        case UTILITY:
            break;
        case IMMUTABLE:
            reqs = EnumSet.of(ServiceOption.PERSISTENCE);
            antiReqs = EnumSet.of(ServiceOption.PERIODIC_MAINTENANCE,
                    ServiceOption.INSTRUMENTATION);
            break;
        case TRANSACTION_PENDING:
            break;
        case STATELESS:
            antiReqs = EnumSet.of(ServiceOption.PERSISTENCE, ServiceOption.REPLICATION,
                    ServiceOption.STRICT_UPDATE_CHECKING);
            break;
        default:
            break;
        }

        if (reqs.isEmpty() && antiReqs.isEmpty()) {
            return null;
        }

        if (!reqs.isEmpty()) {
            EnumSet<ServiceOption> missingReqs = EnumSet.noneOf(ServiceOption.class);
            for (ServiceOption r : reqs) {
                if (!options.contains(r)) {
                    missingReqs.add(r);
                }
            }

            if (!missingReqs.isEmpty()) {
                String error = String
                        .format("%s missing required options: %s", option, missingReqs);
                return error;
            }
        }

        EnumSet<ServiceOption> conflictReqs = EnumSet.noneOf(ServiceOption.class);
        for (ServiceOption r : antiReqs) {
            if (options.contains(r)) {
                conflictReqs.add(r);
            }
        }

        if (!conflictReqs.isEmpty()) {
            String error = String.format("%s conflicts with options: %s", option, conflictReqs);
            return error;
        }

        return null;
    }

    private  Utils();

}