/*
 * Trident - A Multithreaded Server Alternative
 * Copyright 2014 The TridentSDK Team
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package net.tridentsdk.factory;

import net.tridentsdk.DisplayInfo;
import net.tridentsdk.concurrent.HeldValueLatch;
import net.tridentsdk.docs.InternalUseOnly;

import javax.annotation.concurrent.ThreadSafe;

/**
 * Available creational factories for basic objects <p/> <p>If the factories are accessed before initialization, the
 * caller thread will block</p> <p/> <p>This is managed by using a {@link net.tridentsdk.concurrent.HeldValueLatch},
 * instead of a single latch. If a class needs to be initialized that uses another factory, it will never occur because
 * the thread is setting a value after the previous initialization is blocked because it was not fully initialized.</p>
 *
 * @author The TridentSDK Team
 */
@ThreadSafe
public final class Factories {
    private static final HeldValueLatch<TaskFactory> taskFactory = HeldValueLatch.create();
    private static final HeldValueLatch<ThreadFactory> threadFactory = HeldValueLatch.create();
    private static final HeldValueLatch<CollectFactory> collectFactory = HeldValueLatch.create();

    private static final ConfigFactory configFactory = new ConfigFactory();
    private static final ReflectFactory reflectionFactory = new ReflectFactory();
    private static final DisplayInfo INFO = new DisplayInfo();

    private Factories() {
    }

    @InternalUseOnly
    public static void init(TaskFactory factory) {
        taskFactory.countDown(factory);
    }

    @InternalUseOnly
    public static void init(ThreadFactory factory) {
        threadFactory.countDown(factory);
    }

    @InternalUseOnly
    public static void init(CollectFactory factory) {
        collectFactory.countDown(factory);
    }

    /**
     * Schedulers and task executors
     *
     * @return the task factory
     */
    public static TaskFactory tasks() {
        try {
            return taskFactory.await();
        } catch (InterruptedException e) {
            // Release up the stack
            Thread.currentThread().interrupt();
            return null;
        }
    }

    /**
     * Thread management, thread creators/assignment
     *
     * @return the threads factory
     */
    public static ThreadFactory threads() {
        try {
            return threadFactory.await();
        } catch (InterruptedException e) {
            // Release up the stack
            Thread.currentThread().interrupt();
            return null;
        }
    }

    /**
     * Reflection shortcuts and fast wrappers
     *
     * @return the reflection factory
     */
    public static ReflectFactory reflect() {
        return reflectionFactory;
    }

    /**
     * Reimplemented or new backed collections
     *
     * @return the collection factory
     */
    public static CollectFactory collect() {
        try {
            return collectFactory.await();
        } catch (InterruptedException e) {
            // Release up the stack
            Thread.currentThread().interrupt();
            return null;
        }
    }

    /**
     * Public server information displayed to the client
     *
     * @return the server information modifiers and getters
     */
    public static DisplayInfo serverInfo() {
        return INFO;
    }

    /**
     * Deals with configurations and files
     *
     * @return the configuration factory
     */
    public static ConfigFactory configs() {
        return configFactory;
    }
}

@@ -1861,71 +1861,12 @@
 y();
-%0A
     
-private static final DisplayInfo INFO = new DisplayInfo();
 %0A%0A  
@@ -3574,221 +3574,8 @@
  %7D%0A%0A
-    /**%0A     * Public server information displayed to the client%0A     *%0A     * @return the server information modifiers and getters%0A     */%0A    public static DisplayInfo serverInfo() %7B%0A        return INFO;%0A    %7D%0A%0A
     

Update Factories.java