本文整理汇总了Java中org.spongepowered.api.data.persistence.DataBuilder类的典型用法代码示例。如果您正苦于以下问题:Java DataBuilder类的具体用法?Java DataBuilder怎么用?Java DataBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataBuilder类属于org.spongepowered.api.data.persistence包,在下文中一共展示了DataBuilder类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: registerBuilder
import org.spongepowered.api.data.persistence.DataBuilder; //导入依赖的package包/类
@Override
public <T extends DataSerializable> void registerBuilder(Class<T> clazz, DataBuilder<T> builder) {
checkNotNull(clazz);
checkNotNull(builder);
checkState(this.allowRegistrations);
if (!this.builders.containsKey(clazz)) {
if (!(builder instanceof AbstractDataBuilder)) {
this.logger.warn("A custom DataBuilder is not extending AbstractDataBuilder! It is recommended that "
+ "the custom data builder does extend it to gain automated content versioning updates and maintain "
+ "simplicity. The offending builder's class is: {}", builder.getClass());
}
this.builders.put(clazz, builder);
} else {
this.logger.warn("A DataBuilder has already been registered for {}. Attempted to register {} instead.", clazz,
builder.getClass());
}
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:18,代码来源:LanternDataManager.java
示例2: deserialize
import org.spongepowered.api.data.persistence.DataBuilder; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public DataSerializable deserialize(TypeToken<?> type, DataTypeSerializerContext ctx, DataView data) throws InvalidDataException {
final DataBuilder<DataSerializable> dataBuilder = (DataBuilder<DataSerializable>) Lantern.getGame().getDataManager()
.getBuilder((Class<? extends DataSerializable>) type.getRawType())
.orElseThrow(() -> new IllegalStateException("Wasn't able to find a DataBuilder for the DataSerializable: " + type));
return dataBuilder.build(data).orElseThrow(() -> new InvalidDataException("Unable to deserializer the " + type));
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:9,代码来源:DataTypeSerializers.java
示例3: getBuilder
import org.spongepowered.api.data.persistence.DataBuilder; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "SuspiciousMethodCalls"})
@Override
public <T extends DataSerializable> Optional<DataBuilder<T>> getBuilder(Class<T> objectClass) {
checkNotNull(objectClass, "objectClass");
if (this.builders.containsKey(objectClass)) {
return Optional.of((DataBuilder<T>) this.builders.get(objectClass));
} else if (this.builderMap.containsKey(objectClass)) {
return Optional.of((DataBuilder<T>) this.builderMap.get(objectClass));
} else if (this.immutableDataBuilderMap.containsKey(objectClass)) {
return Optional.of((DataBuilder<T>) this.immutableDataBuilderMap.get(objectClass));
} else {
return Optional.empty();
}
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:15,代码来源:LanternDataManager.java
示例4: apply
import org.spongepowered.api.data.persistence.DataBuilder; //导入依赖的package包/类
@Override
public C apply(JsonObject jsonObject) {
final DataBuilder<C> builder = Sponge.getDataManager().getBuilder(this.dataConfigClass).get();
try {
final DataView dataView = JsonDataFormat.serialize(GSON, jsonObject);
return builder.build(dataView).get();
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:11,代码来源:LanternTriggerBuilder.java
示例5: deserialize
import org.spongepowered.api.data.persistence.DataBuilder; //导入依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public DataSerializable deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException {
final DataManager dataManager = Sponge.getDataManager();
final Optional<DataBuilder<?>> builderOpt = (Optional) dataManager.getBuilder(type.getRawType().asSubclass(DataSerializable.class));
if (!builderOpt.isPresent()) {
throw new ObjectMappingException("No data builder is registered for " + type);
}
final Optional<? extends DataSerializable> built = builderOpt.get().build(ConfigurateTranslator.instance().translate(value));
if (!built.isPresent()) {
throw new ObjectMappingException("Unable to build instance of " + type);
}
return built.get();
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:15,代码来源:DataSerializableTypeSerializer.java
示例6: from
import org.spongepowered.api.data.persistence.DataBuilder; //导入依赖的package包/类
@Override
public DataBuilder<RottenData> from(RottenData value) {
lastUpdate = value.getLastUpdate();
age = value.getAge();
return this;
}
开发者ID:TBlueF,项目名称:RottenFood,代码行数:7,代码来源:RottenDataBuilder.java
示例7: reset
import org.spongepowered.api.data.persistence.DataBuilder; //导入依赖的package包/类
@Override
public DataBuilder<RottenData> reset() {
lastUpdate = -1;
age = 0;
return this;
}
开发者ID:TBlueF,项目名称:RottenFood,代码行数:7,代码来源:RottenDataBuilder.java
示例8: deserialize
import org.spongepowered.api.data.persistence.DataBuilder; //导入依赖的package包/类
@Override
public <T extends DataSerializable> Optional<T> deserialize(Class<T> clazz, DataView dataView) {
checkNotNull(dataView, "dataView");
final Optional<DataBuilder<T>> optional = getBuilder(clazz);
return optional.flatMap(builder -> builder.build(dataView));
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:7,代码来源:LanternDataManager.java
示例9: getImmutableDataBuilder
import org.spongepowered.api.data.persistence.DataBuilder; //导入依赖的package包/类
@Override
public DataBuilder<I> getImmutableDataBuilder() {
return this.immutableDataBuilder;
}
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:5,代码来源:AbstractDataManipulatorRegistration.java
示例10: getImmutableDataBuilder
import org.spongepowered.api.data.persistence.DataBuilder; //导入依赖的package包/类
DataBuilder<I> getImmutableDataBuilder();
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:2,代码来源:DataManipulatorRegistration.java
注:本文中的org.spongepowered.api.data.persistence.DataBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论