• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ImmutableDataManipulator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.spongepowered.api.data.manipulator.ImmutableDataManipulator的典型用法代码示例。如果您正苦于以下问题:Java ImmutableDataManipulator类的具体用法?Java ImmutableDataManipulator怎么用?Java ImmutableDataManipulator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ImmutableDataManipulator类属于org.spongepowered.api.data.manipulator包,在下文中一共展示了ImmutableDataManipulator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getContainers

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@Override
default List<ImmutableDataManipulator<?, ?>> getContainers() {
    final ImmutableList.Builder<ImmutableDataManipulator<?, ?>> builder = ImmutableList.builder();
    for (DataManipulatorRegistration registration : DataManipulatorRegistry.get().getAll()) {
        final ImmutableDataManipulator manipulator = (ImmutableDataManipulator) ImmutableContainerCache.get(
                this, registration, registration.getImmutableManipulatorClass()).orElse(null);
        if (manipulator != null) {
            builder.add(manipulator);
        }
    }

    if (this instanceof AdditionalContainerHolder) {
        final AdditionalContainerCollection<ImmutableDataManipulator<?, ?>> manipulators =
                ((AdditionalContainerHolder<ImmutableDataManipulator<?, ?>>) this).getAdditionalContainers();
        manipulators.getAll().forEach(builder::add);
    }

    return builder.build();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:20,代码来源:IImmutableDataHolderBase.java


示例2: get

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@Override
default <T extends DataManipulator<?,?>> Optional<T> get(Class<T> containerClass) {
    checkNotNull(containerClass, "containerClass");

    // Check default registrations
    final Optional<DataManipulatorRegistration> optRegistration = DataManipulatorRegistry.get().getBy(containerClass);
    if (optRegistration.isPresent()) {
        final DataManipulator manipulator = DataHelper.create(this, optRegistration.get());
        return manipulator == null ? Optional.empty() : Optional.of(
                (T) (ImmutableDataManipulator.class.isAssignableFrom(containerClass) ? manipulator.asImmutable() : manipulator));
    }

    // Try the additional containers if they are supported
    if (this instanceof AdditionalContainerHolder) {
        final AdditionalContainerCollection<DataManipulator<?,?>> containers =
                ((AdditionalContainerHolder<DataManipulator<?,?>>) this).getAdditionalContainers();
        return containers.get(containerClass);
    }

    return Optional.empty();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:22,代码来源:IDataHolder.java


示例3: merge

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@Override
public BlockState merge(BlockState that) {
    if (!getType().equals(that.getType())) {
        return this;
    } else {
        BlockState temp = this;
        for (ImmutableDataManipulator<?, ?> manipulator : that.getManipulators()) {
            Optional<BlockState> optional = temp.with(manipulator);
            if (optional.isPresent()) {
                temp = optional.get();
            } else {
                return temp;
            }
        }
        return temp;
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:18,代码来源:LanternBlockState.java


示例4: getAdditionalContainers

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@Override
public AdditionalContainerCollection<ImmutableDataManipulator<?, ?>> getAdditionalContainers() {
    if (this.additionalContainers == null) {
        this.additionalContainers = new MutableToImmutableManipulatorCollection(this.fluidStack.getAdditionalContainers());
    }
    return this.additionalContainers;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:LanternFluidStackSnapshot.java


示例5: with

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@Override
public Optional<FluidStackSnapshot> with(ImmutableDataManipulator<?, ?> valueContainer) {
    final LanternFluidStack copy = this.fluidStack.copy();
    if (copy.offerFast(valueContainer.asMutable())) {
        return Optional.of(new LanternFluidStackSnapshot(copy));
    }
    return Optional.empty();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:LanternFluidStackSnapshot.java


示例6: without

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Optional<FluidStackSnapshot> without(Class<? extends ImmutableDataManipulator<?, ?>> containerClass) {
    final LanternFluidStack copy = this.fluidStack.copy();
    final DataRegistration registration = Lantern.getGame().getDataManager().get(containerClass)
            .orElseThrow(() -> new IllegalStateException("The container class " + containerClass.getName() + " isn't registered."));
    if (copy.removeFast(registration.getManipulatorClass())) {
        return Optional.of(new LanternFluidStackSnapshot(copy));
    }
    return Optional.empty();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:12,代码来源:LanternFluidStackSnapshot.java


示例7: supports

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@Override
default boolean supports(Class<? extends ImmutableDataManipulator<?, ?>> containerClass) {
    // Offer all the default key values as long if they are supported
    // Support all the additional manipulators
    return DataManipulatorRegistry.get().getBy(containerClass)
            .map(registration -> DataHelper.supports(this, registration))
            .orElse(this instanceof AdditionalContainerHolder);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:IImmutableDataHolderBase.java


示例8: removeFastNoEvents

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
default boolean removeFastNoEvents(Key<?> key) {
    checkNotNull(key, "key");
    // Check the local key registration
    final KeyRegistration<?, ?> localKeyRegistration = (KeyRegistration<?, ?>) getValueCollection().get((Key) key).orElse(null);
    if (localKeyRegistration != null) {
        return ((Processor<BaseValue<?>, ?>) localKeyRegistration).removeFastFrom(this);
    }

    // Check for a global registration
    final Optional<ValueProcessorKeyRegistration> globalRegistration = LanternValueFactory.get().getKeyRegistration((Key) key);
    if (globalRegistration.isPresent()) {
        return ((Processor<BaseValue<?>, ?>) globalRegistration.get()).removeFastFrom(this);
    }

    // Check if custom data is supported by this container
    if (this instanceof AdditionalContainerHolder) {
        // Check for the custom value containers
        final AdditionalContainerCollection<H> containers = ((AdditionalContainerHolder<H>) this).getAdditionalContainers();
        for (H valueContainer : containers.getAll()) {
            if (valueContainer.supports(key)) {
                if (valueContainer instanceof ICompositeValueStore) {
                    return ((ICompositeValueStore) valueContainer).removeFastNoEvents(key);
                } else if (valueContainer instanceof CompositeValueStore) {
                    return ((CompositeValueStore) valueContainer).remove(key).isSuccessful();
                } else if (valueContainer instanceof DataManipulator ||
                        valueContainer instanceof ImmutableDataManipulator) {
                    return false;
                }
                return false;
            }
        }
    }

    return false;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:36,代码来源:ICompositeValueStore.java


示例9: get

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "ConstantConditions"})
static <I extends ImmutableDataManipulator<I, M>, M extends DataManipulator<M, I>> Optional<I> get(
        IImmutableDataHolderBase<?> dataHolder, DataManipulatorRegistration<M, I> registration, Class<?> containerClass) {
    final DataManipulator manipulator = registration.createMutable();
    final ImmutableContainerCache cache = dataHolder.getContainerCache();
    if (cache != null && cache.manipulators == null) {
        cache.manipulators = new HashMap<>();
    }
    for (Key key : registration.getRequiredKeys()) {
        final Optional value = dataHolder.getValue(key);
        if (!value.isPresent()) {
            if (cache != null) {
                cache.manipulators.put(containerClass, ImmutableContainerCache.NONE);
            }
            return Optional.empty();
        }
        manipulator.set(key, value.get());
    }
    final I immutable = (I) manipulator.asImmutable();
    if (cache != null) {
        cache.manipulators.put(containerClass, immutable);
        // In case they are different, unlikely
        if (registration.getImmutableManipulatorClass() != containerClass) {
            cache.manipulators.put(registration.getImmutableManipulatorClass(), immutable);
        }
    }
    return Optional.of(immutable);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:29,代码来源:IImmutableValueHolder.java


示例10: validateRegistration

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
<M extends DataManipulator<M, I>, I extends ImmutableDataManipulator<I, M>> void validateRegistration(
        LanternDataRegistration<M, I> registration) {
    checkState(this.allowRegistrations, "Registrations are no longer allowed");
    final Class<M> manipulatorClass = registration.getManipulatorClass();
    final Class<I> immutableClass = registration.getImmutableManipulatorClass();
    final DataManipulatorBuilder<M, I> manipulatorBuilder = registration.getDataManipulatorBuilder();
    checkState(!this.builders.containsKey(manipulatorClass), "DataManipulator already registered!");
    checkState(!this.builderMap.containsKey(manipulatorClass), "DataManipulator already registered!");
    checkState(!this.builderMap.containsValue(manipulatorBuilder), "DataManipulatorBuilder already registered!");
    checkState(!this.builders.containsKey(immutableClass), "ImmutableDataManipulator already registered!");
    checkState(!this.immutableBuilderMap.containsKey(immutableClass), "ImmutableDataManipulator already registered!");
    checkState(!this.immutableBuilderMap.containsValue(manipulatorBuilder), "DataManipulatorBuilder already registered!");
    checkState(!DataManipulatorRegistryModule.get().getById(registration.getId()).isPresent(),
            "There is already a DataRegistration registered with the ID: " + registration.getId());
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:16,代码来源:LanternDataManager.java


示例11: register

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
<M extends DataManipulator<M, I>, I extends ImmutableDataManipulator<I, M>> void register(LanternDataRegistration<M, I> registration) {
    checkNotNull(registration, "registration");
    if (registration instanceof DataManipulatorRegistration) {
        registerBuilder(registration.getImmutableManipulatorClass(),
                ((DataManipulatorRegistration) registration).getImmutableDataBuilder());
    }
    this.registrationsByPlugin.put(registration.getPluginContainer(), registration.getManipulatorClass());
    this.registrations.put(registration.getManipulatorClass(), registration);
    this.registrations.put(registration.getImmutableManipulatorClass(), registration);
    registerBuilder(registration.getManipulatorClass(), registration.getDataManipulatorBuilder());
    DataManipulatorRegistryModule.get().registerAdditionalCatalog(registration);
    Copyable.register(registration.getManipulatorClass(), DataManipulator::copy);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:15,代码来源:LanternDataManager.java


示例12: dataClass

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public  <D extends DataManipulator<D, C>, C extends ImmutableDataManipulator<C, D>> LanternDataRegistrationBuilder<D, C> dataClass(Class<D> manipulatorClass) {
    this.manipulatorClass = (Class<M>) checkNotNull(manipulatorClass,
            "DataManipulator class cannot be null!");
    return (LanternDataRegistrationBuilder<D, C>) this;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:LanternDataRegistrationBuilder.java


示例13: getMap

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@Override
public Map<Class<? extends ImmutableDataManipulator<?, ?>>, ? extends ImmutableDataManipulator<?, ?>> getMap() {
    this.collection.getAll().forEach(manipulator -> {
        final Class<? extends ImmutableDataManipulator<?, ?>> immutableClass = getImmutableClass(manipulator.getClass());
        this.cache.computeIfAbsent(immutableClass, c -> Optional.of(manipulator.asImmutable()));
    });
    return (Map) this.unmodifiableCache;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:MutableToImmutableManipulatorCollection.java


示例14: newRegistrationFor

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <M extends DataManipulator<M, I>, I extends ImmutableDataManipulator<I, M>> DataManipulatorRegistration<M, I> newRegistrationFor(
        PluginContainer pluginContainer, String id, String name,
        Class<M> manipulatorType, Class<I> immutableManipulatorType,
        @Nullable Class<? extends M> mutableExpansion, @Nullable Class<? extends I> immutableExpansion,
        @Nullable Consumer<ValueCollection> registrationConsumer) {
    Class<?>[] classes = mutableExpansion == null ?
            new Class[] { AbstractData.class, manipulatorType } :
            new Class[] { AbstractData.class, manipulatorType, mutableExpansion };
    final List<Method> mutableMethods = findValueMethods(classes);
    classes = mutableExpansion == null ?
            new Class[] { AbstractImmutableData.class, immutableManipulatorType } :
            new Class[] { AbstractImmutableData.class, immutableManipulatorType, immutableExpansion };
    final List<Method> immutableMethods = findValueMethods(classes);

    final Base<M, I> base = generateBase(this.abstractDataTypeGenerator, pluginContainer, id, name,
            manipulatorType, immutableManipulatorType, mutableExpansion, immutableExpansion, mutableMethods, immutableMethods);
    try {
        base.mutableManipulatorTypeImpl.getField(AbstractDataTypeGenerator.REGISTRATION_CONSUMER).set(null, registrationConsumer);
        base.immutableManipulatorTypeImpl.getField(AbstractDataTypeGenerator.REGISTRATION_CONSUMER).set(null, registrationConsumer);

        final DataManipulatorRegistration<M, I> registration = base.supplier.get();
        final Set<Key<?>> requiredKeys = registration.getRequiredKeys();

        base.mutableManipulatorTypeImpl.getField(TypeGenerator.KEYS).set(null, findKeyMatches(mutableMethods, requiredKeys));
        base.immutableManipulatorTypeImpl.getField(TypeGenerator.KEYS).set(null, findKeyMatches(immutableMethods, requiredKeys));

        return registration;
    } catch (IllegalAccessException | NoSuchFieldException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:33,代码来源:DataManipulatorGenerator.java


示例15: generateClasses

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
abstract <M extends DataManipulator<M, I>, I extends ImmutableDataManipulator<I, M>> void generateClasses(
ClassWriter cwM, ClassWriter cwI,
String mutableClassName, String immutableClassName,
Class<M> manipulatorType, Class<I> immutableManipulatorType,
@Nullable Class<? extends M> mutableExpansion,
@Nullable Class<? extends I> immutableExpansion,
@Nullable List<Method> mutableMethods,
@Nullable List<Method> immutableMethods);
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:TypeGenerator.java


示例16: register

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <M extends DataManipulator<M, I>, I extends ImmutableDataManipulator<I, M>> DataManipulatorRegistration<M, I> register(
        Class<M> manipulatorType, Supplier<M> manipulatorSupplier, Function<M, M> manipulatorCopyFunction, Function<I, M> immutableToMutableFunction,
        Class<I> immutableManipulatorType, Supplier<I> immutableManipulatorSupplier, Function<M, I> mutableToImmutableFunction) {
    final RegistrationInfo registrationInfo = RegistrationInfo.build(manipulatorType);
    return register(registrationInfo.pluginContainer, registrationInfo.id, registrationInfo.name, manipulatorType, manipulatorSupplier,
            manipulatorCopyFunction, immutableToMutableFunction, immutableManipulatorType, immutableManipulatorSupplier,
            mutableToImmutableFunction);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:10,代码来源:DataManipulatorRegistry.java


示例17: with

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@Override
public Optional<BlockState> with(ImmutableDataManipulator<?, ?> valueContainer) {
    Optional<BlockState> state = null;
    for (ImmutableValue<?> value : valueContainer.getValues()) {
        state = this.with(value);
        if (!state.isPresent()) {
            return state;
        }
    }
    return state == null ? Optional.of(this) : state;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:12,代码来源:LanternBlockState.java


示例18: add

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@Override
public LanternBlockStateBuilder add(ImmutableDataManipulator<?, ?> manipulator) {
    final Optional<BlockState> optional = this.blockState.with(manipulator);
    if (optional.isPresent()) {
        this.blockState = optional.get();
    }
    return this;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:LanternBlockStateBuilder.java


示例19: getAdditionalContainers

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@Override
public AdditionalContainerCollection<ImmutableDataManipulator<?,?>> getAdditionalContainers() {
    if (this.additionalContainers == null) {
        this.additionalContainers = new MutableToImmutableManipulatorCollection(this.itemStack.getAdditionalContainers());
    }
    return this.additionalContainers;
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:8,代码来源:LanternItemStackSnapshot.java


示例20: with

import org.spongepowered.api.data.manipulator.ImmutableDataManipulator; //导入依赖的package包/类
@Override
public Optional<ItemStackSnapshot> with(ImmutableDataManipulator<?, ?> valueContainer) {
    final LanternItemStack copy = this.itemStack.copy();
    if (copy.offerFast(valueContainer.asMutable())) {
        return Optional.of(new LanternItemStackSnapshot(copy));
    }
    return Optional.empty();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:LanternItemStackSnapshot.java



注:本文中的org.spongepowered.api.data.manipulator.ImmutableDataManipulator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ClientConstants类代码示例发布时间:2022-05-23
下一篇:
Java ListExpression类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap