当前位置: 首页>>代码示例>>Java>>正文


Java CompositeValueStore类代码示例

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


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

示例1: offerFast

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的package包/类
protected static <H extends ValueContainer<?>> boolean offerFast(ICompositeValueStore<?, H> store, H valueContainer, MergeFunction function) {
    final CompositeValueStore store1 = store; // Leave this, the compiler complains
    if (store1 instanceof DataHolder) {
        final boolean hasListeners = hasListeners(store, store.getKeys());
        if (hasListeners) {
            return offer(store, valueContainer, function, () -> true).isSuccessful();
        }
    }
    return store.offerFastNoEvents(valueContainer, function);
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:11,代码来源:CompositeValueStoreHelper.java

示例2: offerFastNoEvents

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的package包/类
default <E> boolean offerFastNoEvents(Key<? extends BaseValue<E>> key, E element) {
    // Check the local key registration
    final KeyRegistration<?, ?> localKeyRegistration = (KeyRegistration<?, ?>) getValueCollection().get((Key) key).orElse(null);
    if (localKeyRegistration != null) {
        return ((Processor<BaseValue<E>, E>) localKeyRegistration).offerFastTo(this, element);
    }

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

    // 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).offerFastNoEvents(key, element);
                } else if (valueContainer instanceof CompositeValueStore) {
                    return ((CompositeValueStore) valueContainer).offer(key, element).isSuccessful();
                } else if (valueContainer instanceof DataManipulator) {
                    ((DataManipulator) valueContainer).set(key, element);
                    return true;
                } else {
                    return false;
                }
            }
        }
    }

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

示例3: removeFastNoEvents

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的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

示例4: removeNoEvents

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的package包/类
default DataTransactionResult removeNoEvents(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).removeFrom(this);
    }

    // Check for a global registration
    final Optional<ValueProcessorKeyRegistration> globalRegistration = LanternValueFactory.get().getKeyRegistration((Key) key);
    if (globalRegistration.isPresent()) {
        return ((Processor<BaseValue<?>, ?>) globalRegistration.get()).removeFrom(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).removeNoEvents(key);
                } else if (valueContainer instanceof CompositeValueStore) {
                    return ((CompositeValueStore) valueContainer).remove(key);
                }
                return DataTransactionResult.failNoData();
            }
        }
    }

    return DataTransactionResult.failNoData();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:34,代码来源:ICompositeValueStore.java

示例5: isCompositeValueStore0

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的package包/类
private static int isCompositeValueStore0(String className) {
    // One of the interfaces directly implements the CompositeValueStore,
    // directly return true
    if (className.equals(COMPOSITE_VALUE_STORE_NAME)) {
        return 1;
    } else if (className.equals(I_COMPOSITE_VALUE_STORE_NAME)) {
        return 2;
        // Don't process java packages
    } else if (className.startsWith("java.")) {
        return 0;
    }
    final LanternClassLoader classLoader = LanternClassLoader.get();
    // If the class is already loaded, we might as well use it
    final Class<?> c = classLoader.getLoadedClass(className.replace('/', '.')).orElse(null);
    if (c != null) {
        return ICompositeValueStore.class.isAssignableFrom(c) ? 2 :
                CompositeValueStore.class.isAssignableFrom(c) ? 1 : 0;
    }

    try {
        // Read the bytecode of the class we need to analyze
        final byte[] byteCode = classLoader.readByteCode(className);

        // Also check for interfaces, super classes, etc.
        final ClassReader classReader = new ClassReader(byteCode);
        final FastValueContainerCheckerClassVisitor classVisitor = new FastValueContainerCheckerClassVisitor(null, false);
        classReader.accept(classVisitor, ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES | ClassReader.SKIP_DEBUG);

        return classVisitor.result;
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:34,代码来源:FastValueContainerCheckerClassVisitor.java

示例6: getEnchantment

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的package包/类
public static List<ItemEnchantment> getEnchantment(CompositeValueStore<?, ?> valueStore, Enchantment enchantment) {
  Optional<List<ItemEnchantment>> results = valueStore.get(Keys.ITEM_ENCHANTMENTS);
  if (results.isPresent()) {
    List<ItemEnchantment> enchantments = results.get();
    return enchantments.stream().filter(e -> e.getEnchantment().equals(enchantment)).collect(Collectors.toList());
  }
  return Lists.newArrayList();
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:9,代码来源:EnchantmentUtil.java

示例7: getHighestEnchantment

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的package包/类
public static Optional<ItemEnchantment> getHighestEnchantment(CompositeValueStore<?, ?> valueStore, Enchantment enchantment) {
  List<ItemEnchantment> enchantments = getEnchantment(valueStore, enchantment);
  if (!enchantments.isEmpty()) {
    return Optional.of(enchantments.stream().sorted(Comparator.comparingInt(ItemEnchantment::getLevel)).findFirst().get());
  }
  return Optional.empty();
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:8,代码来源:EnchantmentUtil.java

示例8: apply

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的package包/类
public <S extends CompositeValueStore<S, H>, H extends ValueContainer<?> > boolean apply(CompositeValueStore<S, H> object) {
	return object.offer(this.key, this.value).isSuccessful();
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:4,代码来源:UtilsKeys.java

示例9: contains

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的package包/类
public <S extends CompositeValueStore<S, H>, H extends ValueContainer<?> > boolean contains(CompositeValueStore<S, H> object) {
	return object.get(this.key).filter(value -> value.equals(this.value)).isPresent();
}
 
开发者ID:EverCraft,项目名称:EverAPI,代码行数:4,代码来源:UtilsKeys.java

示例10: offerNoEvents

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的package包/类
default <E> DataTransactionResult offerNoEvents(Key<? extends BaseValue<E>> key, E element) {
    // Check the local key registration
    final KeyRegistration<?, ?> localKeyRegistration = (KeyRegistration<?, ?>) getValueCollection().get((Key) key).orElse(null);
    if (localKeyRegistration != null) {
        return ((Processor<BaseValue<E>, E>) localKeyRegistration).offerTo(this, element);
    }

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

    // 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).offerNoEvents(key, element);
                } else if (valueContainer instanceof CompositeValueStore) {
                    return ((CompositeValueStore) valueContainer).offer(key, element);
                } else if (valueContainer instanceof DataManipulator) {
                    final ImmutableValue oldImmutableValue = (ImmutableValue) valueContainer.getValue((Key) key)
                            .map(value -> ValueHelper.toImmutable((BaseValue) value))
                            .orElse(null);
                    ((DataManipulator) valueContainer).set(key, element);
                    final ImmutableValue immutableValue = (ImmutableValue) valueContainer.getValue((Key) key)
                            .map(value -> ValueHelper.toImmutable((BaseValue) value))
                            .orElse(null);
                    if (oldImmutableValue == null && immutableValue == null) {
                        return DataTransactionResult.successNoData();
                    } else if (oldImmutableValue == null) {
                        return DataTransactionResult.successResult(immutableValue);
                    } else if (immutableValue == null) {
                        return DataTransactionResult.successRemove(oldImmutableValue);
                    } else {
                        return DataTransactionResult.successReplaceResult(immutableValue, oldImmutableValue);
                    }
                } else {
                    // TODO: Support immutable manipulators?
                    return DataTransactionResult.failNoData();
                }
            }
        }
    }

    return DataTransactionResult.failNoData();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:51,代码来源:ICompositeValueStore.java

示例11: transform

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的package包/类
public static <E> boolean transform(CompositeValueStore<?,?> store, Key<? extends BaseValue<E>> key, Function<E, E> function) {
    return store instanceof ICompositeValueStore ? ((ICompositeValueStore<?,?>) store).transformFast(key, function) :
            store.transform(key, function).isSuccessful();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:FastCompositeValueStoreHelper.java

示例12: offer

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的package包/类
public static <E> boolean offer(CompositeValueStore<?,?> store, Key<? extends BaseValue<E>> key, E element) {
    return store instanceof ICompositeValueStore ? ((ICompositeValueStore<?,?>) store).offerFast(key, element) :
            store.offer(key, element).isSuccessful();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:FastCompositeValueStoreHelper.java

示例13: tryOffer

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的package包/类
public static <E> boolean tryOffer(CompositeValueStore<?,?> store, Key<? extends BaseValue<E>> key, E value) throws IllegalArgumentException {
    return store instanceof ICompositeValueStore ? ((ICompositeValueStore<?,?>) store).tryOfferFast(key, value) :
            store.tryOffer(key, value).isSuccessful();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:FastCompositeValueStoreHelper.java

示例14: remove

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的package包/类
public static boolean remove(CompositeValueStore<?,?> store, Key<?> key) {
    return store instanceof ICompositeValueStore ? ((ICompositeValueStore<?,?>) store).removeFast(key) :
            store.remove(key).isSuccessful();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:FastCompositeValueStoreHelper.java

示例15: undo

import org.spongepowered.api.data.value.mutable.CompositeValueStore; //导入依赖的package包/类
public static boolean undo(CompositeValueStore<?,?> store, DataTransactionResult result) {
    return store instanceof ICompositeValueStore ? ((ICompositeValueStore<?,?>) store).undoFast(result) :
            store.undo(result).isSuccessful();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:FastCompositeValueStoreHelper.java


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