Package org.terasology.reflection.copy

Examples of org.terasology.reflection.copy.CopyStrategyLibrary


    private void initManagers() {
        GameThread.setGameThread();
        ModuleManager moduleManager = CoreRegistry.putPermanently(ModuleManager.class, new ModuleManager());

        ReflectFactory reflectFactory = CoreRegistry.putPermanently(ReflectFactory.class, new ReflectionReflectFactory());
        CopyStrategyLibrary copyStrategyLibrary = CoreRegistry.putPermanently(CopyStrategyLibrary.class, new CopyStrategyLibrary(reflectFactory));

        CoreRegistry.putPermanently(TypeSerializationLibrary.class, new TypeSerializationLibrary(reflectFactory, copyStrategyLibrary));

        AssetManager assetManager = CoreRegistry.putPermanently(AssetManager.class, new AssetManager(moduleManager.getEnvironment()));
        assetManager.setEnvironment(moduleManager.getEnvironment());
View Full Code Here


    }

    public static void applyModules() {
        ModuleManager moduleManager = CoreRegistry.get(ModuleManager.class);

        CopyStrategyLibrary copyStrategyLibrary = CoreRegistry.get(CopyStrategyLibrary.class);
        copyStrategyLibrary.clear();
        for (Class<? extends CopyStrategy> copyStrategy : moduleManager.getEnvironment().getSubtypesOf(CopyStrategy.class)) {
            if (copyStrategy.getAnnotation(RegisterCopyStrategy.class) == null) {
                continue;
            }
            Class targetType = ReflectionUtil.getTypeParameterForSuper(copyStrategy, CopyStrategy.class, 0);
            if (targetType != null) {
                try {
                    copyStrategyLibrary.register(targetType, copyStrategy.newInstance());
                } catch (InstantiationException | IllegalAccessException e) {
                    logger.error("Cannot register CopyStrategy '{}' - failed to instantiate", copyStrategy, e);
                }
            } else {
                logger.error("Cannot register CopyStrategy '{}' - unable to determine target type", copyStrategy);
View Full Code Here

*/
// TODO: Review - This could be a static class but its existence is also questionable.
public class EntitySystemBuilder {

    public EngineEntityManager build(ModuleEnvironment environment, NetworkSystem networkSystem, ReflectFactory reflectFactory) {
        return build(environment, networkSystem, reflectFactory, new CopyStrategyLibrary(reflectFactory));
    }
View Full Code Here

    EntityRef entity;

    @Before
    public void setup() {
        ReflectFactory reflectFactory = new ReflectionReflectFactory();
        CopyStrategyLibrary copyStrategies = new CopyStrategyLibrary(reflectFactory);
        TypeSerializationLibrary serializationLibrary = new TypeSerializationLibrary(reflectFactory, copyStrategies);

        EntitySystemLibrary entitySystemLibrary = new EntitySystemLibrary(reflectFactory, copyStrategies, serializationLibrary);
        compLibrary = entitySystemLibrary.getComponentLibrary();
        entityManager = new PojoEntityManager();
View Full Code Here

    private List<Property<T>> properties = Lists.newArrayList();

    public ReflectionProvider(T target) {
        try {
            ReflectFactory reflectFactory = CoreRegistry.get(ReflectFactory.class);
            CopyStrategyLibrary copyStrategies = CoreRegistry.get(CopyStrategyLibrary.class);
            ClassMetadata<T, ?> classMetadata = new DefaultClassMetadata<>(new SimpleUri(), (Class<T>) target.getClass(), reflectFactory, copyStrategies);
            for (Field field : getAllFields(target.getClass(), and(withAnnotation(EditorRange.class), or(withType(Float.TYPE), withType(Float.class))))) {
                EditorRange range = field.getAnnotation(EditorRange.class);
                FieldMetadata<T, Float> fieldMetadata = (FieldMetadata<T, Float>) classMetadata.getField(field.getName());
                Property property = new FloatProperty(target, fieldMetadata, range.min(), range.max());
View Full Code Here

    @Before
    public void setup() throws Exception {
        ModuleManager moduleManager = ModuleManagerFactory.create();
        ReflectFactory reflectFactory = new ReflectionReflectFactory();
        CopyStrategyLibrary copyStrategyLibrary = new CopyStrategyLibrary(reflectFactory);
        TypeSerializationLibrary lib = new TypeSerializationLibrary(reflectFactory, copyStrategyLibrary);
        lib.add(Vector3f.class, new Vector3fTypeHandler());
        lib.add(Quat4f.class, new Quat4fTypeHandler());
        entitySystemLibrary = new EntitySystemLibrary(reflectFactory, copyStrategyLibrary, lib);
        componentLibrary = entitySystemLibrary.getComponentLibrary();
View Full Code Here

        try {
            this.target = target;
            Class<?> type = target.getClass();

            ReflectFactory reflectFactory = CoreRegistry.get(ReflectFactory.class);
            CopyStrategyLibrary copyStrategies = new CopyStrategyLibrary(reflectFactory);
            ClassMetadata<?, ?> classMetadata = new DefaultClassMetadata<>(new SimpleUri(), type, reflectFactory, copyStrategies);
            for (Field field : getAllFields(type)) {
                Annotation annotation = getFactory(field);
                if (annotation != null) {
                    FieldMetadata<Object, ?> fieldMetadata = (FieldMetadata<Object, ?>) classMetadata.getField(field.getName());
View Full Code Here

    @Before
    public void setup() throws Exception {
        ModuleManager moduleManager = ModuleManagerFactory.create();
        ReflectionReflectFactory reflectFactory = new ReflectionReflectFactory();
        CoreRegistry.put(ReflectFactory.class, reflectFactory);
        CopyStrategyLibrary copyStrategies = new CopyStrategyLibrary(reflectFactory);
        CoreRegistry.put(CopyStrategyLibrary.class, copyStrategies);
        CoreRegistry.put(ModuleManager.class, moduleManager);
        NodesClassLibrary nodesClassLibrary = new NodesClassLibrary(reflectFactory, copyStrategies);
        CoreRegistry.put(NodesClassLibrary.class, nodesClassLibrary);
        nodesClassLibrary.scan(moduleManager.getEnvironment());
View Full Code Here

    @Override
    public UIData load(Module module, InputStream stream, List<URL> urls, List<URL> deltas) throws IOException {
        NUIManager nuiManager = CoreRegistry.get(NUIManager.class);
        ReflectFactory reflectFactory = CoreRegistry.get(ReflectFactory.class);
        CopyStrategyLibrary copyStrategyLibrary = CoreRegistry.get(CopyStrategyLibrary.class);

        // TODO: Get this library from elsewhere
        TypeSerializationLibrary library = new TypeSerializationLibrary(reflectFactory, copyStrategyLibrary);
        library.add(BlockFamily.class, new BlockFamilyTypeHandler());
        library.add(Block.class, new BlockTypeHandler());
View Full Code Here

TOP

Related Classes of org.terasology.reflection.copy.CopyStrategyLibrary

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.