public ImmutableBiMap<ModContainer, Object> buildModObjectList()
{
ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.<ModContainer, Object>builder();
for (ModContainer mc : activeModList)
{
if (!mc.isImmutable() && mc.getMod()!=null)
{
builder.put(mc, mc.getMod());
List<String> packages = mc.getOwnedPackages();
for (String pkg : packages)
{
packageOwners.put(pkg, mc);
}
}
if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING)
{
FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId());
if (state != LoaderState.CONSTRUCTING)
{
this.errorOccurred(mc, new RuntimeException());
}
}
}
return builder.build();
}
java类com.google.common.collect.ImmutableBiMap的实例源码
LoadController.java 文件源码
项目:CauldronGit
阅读 28
收藏 0
点赞 0
评论 0
ExtraCollection.java 文件源码
项目:GitHub
阅读 30
收藏 0
点赞 0
评论 0
default void use() {
ImmutableExtraCollection.of(
ImmutableList.<String>of(),
ImmutableMultimap.<Integer, String>of(),
ImmutableMultimap.<Integer, String>of(),
ImmutableMultimap.<Integer, String>of(),
ImmutableBiMap.<Integer, String>of());
ImmutableExtraCollection.of();
ImmutableExtraCollection collection = ImmutableExtraCollection.builder()
.addBag("2", "2")
.putIndex(1, "2", "3", "4")
.putAllIndex(1, Arrays.asList("2", "3", "4"))
.putIndex(2, "5")
.putIndexList(1, "")
.putIndexSet(2, "2")
.putAllIndexSet(2, Arrays.asList("3", "4"))
.putBiMap(1, "a")
.putBiMap(2, "b")
.putAllBiMap(Collections.singletonMap(3, "c"))
.build();
collection.bag().count("2");
collection.index().get(1);
collection.indexList().get(1);
collection.indexSet().get(2);
}
ClassRenamingMapper.java 文件源码
项目:r8
阅读 22
收藏 0
点赞 0
评论 0
public static ClassRenamingMapper from(ClassNameMapper originalMap, ClassNameMapper targetMap) {
ImmutableBiMap.Builder<String, String> translationBuilder = ImmutableBiMap.builder();
ImmutableSet.Builder<String> newClasses = ImmutableSet.builder();
BiMap<String, String> sourceObfuscatedToOriginal = originalMap.getObfuscatedToOriginalMapping();
BiMap<String, String> sourceOriginalToObfuscated = sourceObfuscatedToOriginal.inverse();
BiMap<String, String> targetObfuscatedToOriginal = targetMap.getObfuscatedToOriginalMapping();
BiMap<String, String> targetOriginalToObfuscated = targetObfuscatedToOriginal.inverse();
for (String originalName : sourceOriginalToObfuscated.keySet()) {
String sourceObfuscatedName = sourceOriginalToObfuscated.get(originalName);
String targetObfuscatedName = targetOriginalToObfuscated.get(originalName);
if (targetObfuscatedName == null) {
newClasses.add(originalName);
continue;
}
translationBuilder.put(sourceObfuscatedName, targetObfuscatedName);
}
ImmutableBiMap<String, String> translation = translationBuilder.build();
ImmutableSet<String> unusedNames = ImmutableSet
.copyOf(Sets.difference(targetObfuscatedToOriginal.keySet(), translation.values()));
return new ClassRenamingMapper(translation, newClasses.build(), unusedNames);
}
QueryResponseFromERE.java 文件源码
项目:tac-kbp-eal
阅读 26
收藏 0
点赞 0
评论 0
private static ImmutableSet<CharOffsetSpan> matchJustificationsForDoc(
final Iterable<DocEventFrameReference> eventFramesMatchedInDoc,
final DocumentSystemOutput2015 docSystemOutput) {
final Optional<ImmutableBiMap<String, ResponseSet>> responseSetMap =
docSystemOutput.linking().responseSetIds();
checkState(responseSetMap.isPresent());
final ImmutableSet.Builder<CharOffsetSpan> offsetsB = ImmutableSet.builder();
for (final DocEventFrameReference docEventFrameReference : eventFramesMatchedInDoc) {
final ResponseSet rs =
checkNotNull(responseSetMap.get().get(docEventFrameReference.eventFrameID()));
final ImmutableSet<Response> responses = rs.asSet();
final ImmutableSet<CharOffsetSpan> spans = FluentIterable.from(responses)
.transformAndConcat(ResponseFunctions.predicateJustifications()).toSet();
offsetsB.addAll(spans);
}
return offsetsB.build();
}
GqlInputConverter.java 文件源码
项目:rejoiner
阅读 34
收藏 0
点赞 0
评论 0
GqlInputConverter build() {
HashBiMap<String, Descriptor> mapping = HashBiMap.create();
HashBiMap<String, EnumDescriptor> enumMapping = HashBiMap.create(getEnumMap(enumDescriptors));
LinkedList<Descriptor> loop = new LinkedList<>(descriptors);
Set<FileDescriptor> fileDescriptorSet = ProtoRegistry.extractDependencies(fileDescriptors);
for (FileDescriptor fileDescriptor : fileDescriptorSet) {
loop.addAll(fileDescriptor.getMessageTypes());
enumMapping.putAll(getEnumMap(fileDescriptor.getEnumTypes()));
}
while (!loop.isEmpty()) {
Descriptor descriptor = loop.pop();
if (!mapping.containsKey(descriptor.getFullName())) {
mapping.put(getReferenceName(descriptor), descriptor);
loop.addAll(descriptor.getNestedTypes());
enumMapping.putAll(getEnumMap(descriptor.getEnumTypes()));
}
}
return new GqlInputConverter(
ImmutableBiMap.copyOf(mapping), ImmutableBiMap.copyOf(enumMapping));
}
HashBiMapDemo.java 文件源码
项目:cakes
阅读 26
收藏 0
点赞 0
评论 0
/**
* HashBiMap 修改数据
* putAll
* remove
* replace
*/
@Test
public void testUpdateBiMapDate() {
BiMap<String, String> biMap = HashBiMap.create();
biMap.put("k1", "v1");
biMap.put("k2", "v2");
// putAll , 存入另一个Map的数据,此时如果value有重复的依然会抛异常
biMap.putAll(ImmutableBiMap.of("k3", "v3", "k4", "v4", "k5", "v5", "k6", "v6"));
System.out.println("biMap putAll after: " + biMap);
System.out.println("\n-------------------------------------------\n");
// remove , 移除指定key的元素,如果key不存在,则返回null
String v2 = biMap.remove("k2");
String valueNotExists = biMap.remove("keyNotExists");
System.out.println("remove k2 then biMap= " + biMap + ", and remove the value= " + v2);
System.out.println("valueNotExists=" + valueNotExists);
System.out.println("\n-------------------------------------------\n");
// 清空map里的数据
biMap.clear();
System.out.println("clean biMap=" + biMap);
}
LoadController.java 文件源码
项目:CustomWorldGen
阅读 36
收藏 0
点赞 0
评论 0
public ImmutableBiMap<ModContainer, Object> buildModObjectList()
{
ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.builder();
for (ModContainer mc : activeModList)
{
if (!mc.isImmutable() && mc.getMod()!=null)
{
builder.put(mc, mc.getMod());
List<String> packages = mc.getOwnedPackages();
for (String pkg : packages)
{
packageOwners.put(pkg, mc);
}
}
if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING)
{
FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId());
if (state != LoaderState.CONSTRUCTING)
{
this.errorOccurred(mc, new RuntimeException());
}
}
}
return builder.build();
}
ModuleShardBackendResolver.java 文件源码
项目:hashsdn-controller
阅读 32
收藏 0
点赞 0
评论 0
Long resolveShardForPath(final YangInstanceIdentifier path) {
final String shardName = actorContext.getShardStrategyFactory().getStrategy(path).findShard(path);
Long cookie = shards.get(shardName);
if (cookie == null) {
synchronized (this) {
cookie = shards.get(shardName);
if (cookie == null) {
cookie = nextShard++;
Builder<String, Long> builder = ImmutableBiMap.builder();
builder.putAll(shards);
builder.put(shardName, cookie);
shards = builder.build();
}
}
}
return cookie;
}
LoadController.java 文件源码
项目:TRHS_Club_Mod_2016
阅读 41
收藏 0
点赞 0
评论 0
public ImmutableBiMap<ModContainer, Object> buildModObjectList()
{
ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.<ModContainer, Object>builder();
for (ModContainer mc : activeModList)
{
if (!mc.isImmutable() && mc.getMod()!=null)
{
builder.put(mc, mc.getMod());
List<String> packages = mc.getOwnedPackages();
for (String pkg : packages)
{
packageOwners.put(pkg, mc);
}
}
if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING)
{
FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId());
if (state != LoaderState.CONSTRUCTING)
{
this.errorOccurred(mc, new RuntimeException());
}
}
}
return builder.build();
}
ModuleRegistry.java 文件源码
项目:Cardinal
阅读 34
收藏 0
点赞 0
评论 0
/**
* Creates a new {@link ModuleRegistry}
*
* @param modules The modules in the registry to be created.
*/
public ModuleRegistry(@NonNull Map<Class, Module> modules) {
Validate.notNull(modules);
this.modules = new ImmutableBiMap.Builder<Class, Module>().putAll(modules).build();
DependencyGraph<Module> graph = new DependencyGraph<Module>();
this.modules.values().forEach(module -> {
graph.add(module);
ModuleEntry moduleEntry = module.getClass().getAnnotation(ModuleEntry.class);
for (Class dep : moduleEntry.depends()) {
graph.addDependency(module, modules.get(dep));
}
for (Class before : moduleEntry.loadBefore()) {
graph.addDependency(modules.get(before), module);
}
});
loadOrder = graph.evaluateDependencies();
}
LanternBlockState.java 文件源码
项目:LanternServer
阅读 24
收藏 0
点赞 0
评论 0
LanternBlockState(LanternBlockStateMap baseState, ImmutableMap<BlockTrait<?>, Comparable<?>> traitValues) {
this.traitValues = traitValues;
this.baseState = baseState;
ImmutableBiMap.Builder<Key<Value<?>>, BlockTrait<?>> builder = ImmutableBiMap.builder();
for (BlockTrait trait : traitValues.keySet()) {
builder.put(((LanternBlockTrait) trait).getKey(), trait);
}
this.keyToBlockTrait = builder.build();
final StringBuilder idBuilder = new StringBuilder();
idBuilder.append(baseState.getBlockType().getId().substring(baseState.getBlockType().getPluginId().length() + 1));
if (!traitValues.isEmpty()) {
idBuilder.append('[');
final Joiner joiner = Joiner.on(',');
final List<String> propertyValues = new ArrayList<>();
for (Map.Entry<BlockTrait<?>, Comparable<?>> entry : traitValues.entrySet()) {
propertyValues.add(entry.getKey().getName() + "=" + entry.getValue().toString().toLowerCase(Locale.ENGLISH));
}
idBuilder.append(joiner.join(propertyValues));
idBuilder.append(']');
}
this.name = idBuilder.toString();
this.id = baseState.getBlockType().getPluginId() + ':' + this.name;
}
XPath.java 文件源码
项目:knowledgestore
阅读 24
收藏 0
点赞 0
评论 0
Support(final Expr expr, final String body, final Set<URI> properties,
final Map<String, String> namespaces) {
super(null, XPathFunction.CONTEXT, VARIABLES, XPathNavigator.INSTANCE);
final StringBuilder builder = new StringBuilder();
for (final String prefix : Ordering.natural().sortedCopy(namespaces.keySet())) {
final String namespace = namespaces.get(prefix);
if (!namespace.equals(Data.getNamespaceMap().get(prefix))) {
builder.append(builder.length() == 0 ? "" : ", ").append(prefix).append(": ")
.append("<").append(namespace).append(">");
}
}
final String head = builder.toString();
this.string = head.isEmpty() ? body : "with " + head + " : " + body;
this.head = head.isEmpty() ? "" : this.string.substring(5, 5 + head.length());
this.body = head.isEmpty() ? body : this.string.substring(8 + head.length());
this.expr = expr;
this.properties = properties;
this.namespaces = ImmutableBiMap.copyOf(namespaces);
}
HierarchicalTypeStore.java 文件源码
项目:incubator-atlas
阅读 22
收藏 0
点赞 0
评论 0
HierarchicalTypeStore(MemRepository repository, HierarchicalType hierarchicalType) throws RepositoryException {
this.hierarchicalType = (IConstructableType) hierarchicalType;
this.repository = repository;
ImmutableMap.Builder<AttributeInfo, IAttributeStore> b =
new ImmutableBiMap.Builder<>();
typeNameList = Lists.newArrayList((String) null);
ImmutableList<AttributeInfo> l = hierarchicalType.immediateAttrs;
for (AttributeInfo i : l) {
b.put(i, AttributeStores.createStore(i));
}
attrStores = b.build();
ImmutableList.Builder<HierarchicalTypeStore> b1 = new ImmutableList.Builder<>();
Set<String> allSuperTypeNames = hierarchicalType.getAllSuperTypeNames();
for (String s : allSuperTypeNames) {
b1.add(repository.getStore(s));
}
superTypeStores = b1.build();
nextPos = 0;
idPosMap = new HashMap<>();
freePositions = new ArrayList<>();
lock = new ReentrantReadWriteLock();
}
RamResourceUsageTrackerTest.java 文件源码
项目:che
阅读 20
收藏 0
点赞 0
评论 0
/** Creates users workspace object based on the status and machines RAM. */
private static WorkspaceImpl createWorkspace(WorkspaceStatus status, Integer... machineRams) {
final Map<String, MachineImpl> machines = new HashMap<>(machineRams.length - 1);
final Map<String, MachineConfigImpl> machineConfigs = new HashMap<>(machineRams.length - 1);
byte i = 1;
for (Integer machineRam : machineRams) {
final String machineName = "machine_" + i++;
machines.put(machineName, createMachine(machineRam));
machineConfigs.put(machineName, createMachineConfig(machineRam));
}
return WorkspaceImpl.builder()
.setConfig(
WorkspaceConfigImpl.builder()
.setEnvironments(
ImmutableBiMap.of(ACTIVE_ENV_NAME, new EnvironmentImpl(null, machineConfigs)))
.build())
.setRuntime(new RuntimeImpl(ACTIVE_ENV_NAME, machines, null))
.setStatus(status)
.build();
}
NeutronTapFlowInterface.java 文件源码
项目:neutron
阅读 29
收藏 0
点赞 0
评论 0
@Override
protected TapFlow toMd(NeutronTapFlow flow) {
final TapFlowBuilder flowBuilder = new TapFlowBuilder();
toMdBaseAttributes(flow, flowBuilder);
if (flow.getTapFlowServiceID() != null) {
flowBuilder.setTapServiceId(toUuid(flow.getTapFlowServiceID()));
}
if (flow.getTapFlowSourcePort() != null) {
flowBuilder.setSourcePort(toUuid(flow.getTapFlowSourcePort()));
}
if (flow.getTapFlowDirection() != null) {
final ImmutableBiMap<String, Class<? extends DirectionBase>> mapper = DIRECTION_MAP.inverse();
flowBuilder.setDirection(mapper.get(flow.getTapFlowDirection()));
}
return flowBuilder.build();
}
NeutronTrunkInterface.java 文件源码
项目:neutron
阅读 23
收藏 0
点赞 0
评论 0
@Override
protected Trunk toMd(NeutronTrunk trunk) {
final TrunkBuilder trunkBuilder = new TrunkBuilder();
toMdAdminAttributes(trunk, trunkBuilder);
if (trunk.getPortId() != null) {
trunkBuilder.setPortId(toUuid(trunk.getPortId()));
}
if (trunk.getSubPorts() != null) {
final List<SubPorts> subPortsList = new ArrayList<>();
final SubPortsBuilder subPortsBuilder = new SubPortsBuilder();
final ImmutableBiMap<String, Class<? extends NetworkTypeBase>> mapper = NETWORK_TYPE_MAP.inverse();
for (NeutronTrunkSubPort subPort: trunk.getSubPorts()) {
subPortsBuilder.setPortId(toUuid(subPort.getPortId()));
subPortsBuilder.setSegmentationType(mapper.get(subPort.getSegmentationType()));
subPortsBuilder.setSegmentationId(Long.valueOf(subPort.getSegmentationId()));
subPortsList.add(subPortsBuilder.build());
}
trunkBuilder.setSubPorts(subPortsList);
}
return trunkBuilder.build();
}
Mappings.java 文件源码
项目:SrgLib
阅读 27
收藏 0
点赞 0
评论 0
/**
* Transform all the original data in the specified mapping, using this mapping.
*
* This is useful for {@link #createRenamingMappings(UnaryOperator, Function, Function)},
* since renaming mappings have no 'original' data of their own, and so can't be directly output to a file.
* The returned mapping data is guaranteed to have the same originals as the data of the old mapping data.
*
* @return the transformed data
*/
default Mappings transform(Mappings original) {
ImmutableBiMap.Builder<JavaType, JavaType> types = ImmutableBiMap.builder();
ImmutableBiMap.Builder<MethodData, MethodData> methods = ImmutableBiMap.builder();
ImmutableBiMap.Builder<FieldData, FieldData> fields = ImmutableBiMap.builder();
original.classes().forEach(originalType -> {
JavaType newType = this.getNewType(originalType);
types.put(originalType, newType);
});
original.methods().forEach(originalMethodData -> {
MethodData newMethodData = this.getNewMethod(originalMethodData);
methods.put(originalMethodData, newMethodData);
});
original.fields().forEach(originalFieldData -> {
FieldData newFieldData = this.getNewField(originalFieldData);
fields.put(originalFieldData, newFieldData);
});
return ImmutableMappings.create(types.build(), methods.build(), fields.build());
}
Leaves2DataConverter.java 文件源码
项目:Pore
阅读 26
收藏 0
点赞 0
评论 0
@SuppressWarnings("rawtypes")
private Leaves2DataConverter() {
converters.put(
ImmutableBiMap.<AbstractDataValue, Byte>builder()
.put(new TreeDataValue(TreeTypes.ACACIA), (byte) 0)
.put(new TreeDataValue(TreeTypes.DARK_OAK), (byte) 1)
.build(),
(byte) 2
);
applicableTypes.add(TreeData.class);
converters.put(
ImmutableBiMap.<AbstractDataValue, Byte>builder()
.put(new DecayableDataValue(false), (byte) 0)
.put(new DecayableDataValue(true), (byte) 1)
.build(),
(byte) 1
);
applicableTypes.add(DecayableData.class);
}
ScannerSupplierImpl.java 文件源码
项目:error-prone
阅读 25
收藏 0
点赞 0
评论 0
ScannerSupplierImpl(
ImmutableBiMap<String, BugCheckerInfo> checks,
ImmutableMap<String, SeverityLevel> severities,
ImmutableSet<String> disabled,
ErrorProneFlags flags) {
checkArgument(
Sets.difference(severities.keySet(), checks.keySet()).isEmpty(),
"enabledChecks must be a subset of allChecks");
checkArgument(
Sets.difference(disabled, checks.keySet()).isEmpty(),
"disabled must be a subset of allChecks");
this.checks = checks;
this.severities = severities;
this.disabled = disabled;
this.flags = flags;
}
ScannerSupplier.java 文件源码
项目:error-prone
阅读 25
收藏 0
点赞 0
评论 0
/**
* Composes this {@link ScannerSupplier} with the {@code other} {@link ScannerSupplier}. The set
* of checks that are turned on is the intersection of the checks on in {@code this} and {@code
* other}.
*/
@CheckReturnValue
public ScannerSupplier plus(ScannerSupplier other) {
ImmutableBiMap<String, BugCheckerInfo> combinedAllChecks =
ImmutableBiMap.<String, BugCheckerInfo>builder()
.putAll(this.getAllChecks())
.putAll(other.getAllChecks())
.build();
ImmutableMap<String, SeverityLevel> combinedSeverities =
ImmutableMap.<String, SeverityLevel>builder()
.putAll(severities())
.putAll(other.severities())
.build();
ImmutableSet<String> disabled = ImmutableSet.copyOf(Sets.union(disabled(), other.disabled()));
ErrorProneFlags combinedFlags = this.getFlags().plus(other.getFlags());
return new ScannerSupplierImpl(combinedAllChecks, combinedSeverities, disabled, combinedFlags);
}
HttpHeadersTest.java 文件源码
项目:guava
阅读 33
收藏 0
点赞 0
评论 0
private static String upperToHttpHeaderName(
String constantName,
ImmutableBiMap<String, String> specialCases,
ImmutableSet<String> uppercaseAcronyms) {
if (specialCases.containsKey(constantName)) {
return specialCases.get(constantName);
}
List<String> parts = Lists.newArrayList();
for (String part : SPLITTER.split(constantName)) {
if (!uppercaseAcronyms.contains(part)) {
part = part.charAt(0) + Ascii.toLowerCase(part.substring(1));
}
parts.add(part);
}
return JOINER.join(parts);
}
HttpHeadersTest.java 文件源码
项目:guava
阅读 36
收藏 0
点赞 0
评论 0
private static String upperToHttpHeaderName(
String constantName,
ImmutableBiMap<String, String> specialCases,
ImmutableSet<String> uppercaseAcronyms) {
if (specialCases.containsKey(constantName)) {
return specialCases.get(constantName);
}
List<String> parts = Lists.newArrayList();
for (String part : SPLITTER.split(constantName)) {
if (!uppercaseAcronyms.contains(part)) {
part = part.charAt(0) + Ascii.toLowerCase(part.substring(1));
}
parts.add(part);
}
return JOINER.join(parts);
}
Environment.java 文件源码
项目:kidneyExchange
阅读 35
收藏 0
点赞 0
评论 0
public Environment(ImmutableBiMap<String, V> nodeIds,
ImmutableBiMap<String, E> edgeIds, int threads,
MultiPeriodCyclePackingInputs<V, E, T> multiPeriodInputs,
TimeWriter<T> timeWriter, ObjectiveBuilder objectiveBuilder,
int replications, PredicateFactory<V, E> predicateFactory,
HistoricData<V, E> historicData) {
this.nodeIds = nodeIds;
this.edgeIds = edgeIds;
this.multiPeriodInputs = multiPeriodInputs;
this.threads = threads;
threadPool = FixedThreadPool.makePool(threads);
maxSolveTimeSeconds = Optional.of(60.0);
solverOptions = SolverOption.defaultOptions;
this.timeWriter = timeWriter;
this.objectiveBuilder = objectiveBuilder;
this.replications = replications;
this.predicateFactory = predicateFactory;
this.historicData = historicData;
}
UnosParseData.java 文件源码
项目:kidneyExchange
阅读 28
收藏 0
点赞 0
评论 0
private ImmutableBiMap<UnosDataHeader, Integer> getHeaderColumns(
CSVRecord headerRow) {
ImmutableBiMap.Builder<UnosDataHeader, Integer> ans = ImmutableBiMap
.builder();
for (int i = 0; i < headerRow.size(); i++) {
String header = headerRow.get(i);
if (dataHeaderNames.inverse().containsKey(header)) {
ans.put(dataHeaderNames.inverse().get(header), i);
}
}
ImmutableBiMap<UnosDataHeader, Integer> ansBuilt = ans.build();
if (ansBuilt.size() != dataHeaderNames.size()) {
throw new RuntimeException("Expected "
+ dataHeaderNames.size()
+ " headers but found: "
+ ansBuilt.size()
+ ". Values: "
+ ansBuilt
+ ", Missing: "
+ Sets.difference(EnumSet.allOf(UnosDataHeader.class),
ansBuilt.keySet()));
}
return ansBuilt;
}
Log2DataConverter.java 文件源码
项目:Pore
阅读 23
收藏 0
点赞 0
评论 0
@SuppressWarnings("rawtypes")
private Log2DataConverter() {
converters.put(
ImmutableBiMap.<AbstractDataValue, Byte>builder()
.put(new LogDataConverter.TreeDataValue(TreeTypes.ACACIA), (byte) 0)
.put(new LogDataConverter.TreeDataValue(TreeTypes.DARK_OAK), (byte) 1)
.build(),
(byte) 2
);
applicableTypes.add(TreeData.class);
converters.put(
ImmutableBiMap.<AbstractDataValue, Byte>builder()
.put(new LogDataConverter.AxisDataValue(Axis.Y), (byte) 0)
.put(new LogDataConverter.AxisDataValue(Axis.X), (byte) 1)
.put(new LogDataConverter.AxisDataValue(Axis.Z), (byte) 2)
.put(new LogDataConverter.AxisDataValue(null), (byte) 3)
.build(),
(byte) 2
);
applicableTypes.add(AxisData.class);
}
LeavesDataConverter.java 文件源码
项目:Pore
阅读 34
收藏 0
点赞 0
评论 0
@SuppressWarnings("rawtypes")
private LeavesDataConverter() {
converters.put(
ImmutableBiMap.<AbstractDataValue, Byte>builder()
.put(new LogDataConverter.TreeDataValue(TreeTypes.OAK), (byte) 0)
.put(new LogDataConverter.TreeDataValue(TreeTypes.SPRUCE), (byte) 1)
.put(new LogDataConverter.TreeDataValue(TreeTypes.BIRCH), (byte) 2)
.put(new LogDataConverter.TreeDataValue(TreeTypes.JUNGLE), (byte) 3)
.build(),
(byte) 2
);
applicableTypes.add(TreeData.class);
converters.put(
ImmutableBiMap.<AbstractDataValue, Byte>builder()
.put(new DecayableDataValue(false), (byte) 0)
.put(new DecayableDataValue(true), (byte) 1)
.build(),
(byte) 1
);
applicableTypes.add(DecayableData.class);
}
CompiledTemplateRegistry.java 文件源码
项目:closure-templates
阅读 52
收藏 0
点赞 0
评论 0
CompiledTemplateRegistry(TemplateRegistry registry) {
Map<String, Optional<SanitizedContentKind>> deltemplateNameToContentKind = new HashMap<>();
ImmutableBiMap.Builder<String, CompiledTemplateMetadata> templateToMetadata =
ImmutableBiMap.builder();
ImmutableBiMap.Builder<String, CompiledTemplateMetadata> classToMetadata =
ImmutableBiMap.builder();
ImmutableSet.Builder<String> delegateTemplateNames = ImmutableSet.builder();
for (TemplateNode template : registry.getAllTemplates()) {
CompiledTemplateMetadata metadata =
CompiledTemplateMetadata.create(template.getTemplateName(), template);
templateToMetadata.put(template.getTemplateName(), metadata);
classToMetadata.put(metadata.typeInfo().className(), metadata);
if (template instanceof TemplateDelegateNode) {
delegateTemplateNames.add(template.getTemplateName());
// all delegates are guaranteed to have the same content kind by the
// checkdelegatesvisitor
deltemplateNameToContentKind.put(
((TemplateDelegateNode) template).getDelTemplateName(),
Optional.fromNullable(template.getContentKind()));
}
}
this.templateNameToMetadata = templateToMetadata.build();
this.classNameToMetadata = classToMetadata.build();
this.deltemplateNameToContentKind = ImmutableMap.copyOf(deltemplateNameToContentKind);
this.delegateTemplateNames = delegateTemplateNames.build();
}
ArgumentUtils.java 文件源码
项目:yangtools
阅读 26
收藏 0
点赞 0
评论 0
public static RevisionAwareXPath parseXPath(final StmtContext<?, ?, ?> ctx, final String path) {
final XPath xPath = XPATH_FACTORY.get().newXPath();
xPath.setNamespaceContext(StmtNamespaceContext.create(ctx,
ImmutableBiMap.of(RFC6020_YANG_NAMESPACE.toString(), YANG_XPATH_FUNCTIONS_PREFIX)));
final String trimmed = trimSingleLastSlashFromXPath(path);
try {
// XPath extension functions have to be prefixed
// yang-specific XPath functions are in fact extended functions, therefore we have to add
// "yang" prefix to them so that they can be properly validated with the XPath.compile() method
// the "yang" prefix is bound to RFC6020 YANG namespace
final String prefixedXPath = addPrefixToYangXPathFunctions(trimmed, ctx);
// TODO: we could capture the result and expose its 'evaluate' method
xPath.compile(prefixedXPath);
} catch (final XPathExpressionException e) {
LOG.warn("Argument \"{}\" is not valid XPath string at \"{}\"", path, ctx.getStatementSourceReference(), e);
}
return new RevisionAwareXPathImpl(path, PATH_ABS.matcher(path).matches());
}
LoadController.java 文件源码
项目:Cauldron
阅读 30
收藏 0
点赞 0
评论 0
public ImmutableBiMap<ModContainer, Object> buildModObjectList()
{
ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.<ModContainer, Object>builder();
for (ModContainer mc : activeModList)
{
if (!mc.isImmutable() && mc.getMod()!=null)
{
builder.put(mc, mc.getMod());
List<String> packages = mc.getOwnedPackages();
for (String pkg : packages)
{
packageOwners.put(pkg, mc);
}
}
if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING)
{
FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId());
if (state != LoaderState.CONSTRUCTING)
{
this.errorOccurred(mc, new RuntimeException());
}
}
}
return builder.build();
}
LoadController.java 文件源码
项目:Cauldron
阅读 64
收藏 0
点赞 0
评论 0
public ImmutableBiMap<ModContainer, Object> buildModObjectList()
{
ImmutableBiMap.Builder<ModContainer, Object> builder = ImmutableBiMap.<ModContainer, Object>builder();
for (ModContainer mc : activeModList)
{
if (!mc.isImmutable() && mc.getMod()!=null)
{
builder.put(mc, mc.getMod());
List<String> packages = mc.getOwnedPackages();
for (String pkg : packages)
{
packageOwners.put(pkg, mc);
}
}
if (mc.getMod()==null && !mc.isImmutable() && state!=LoaderState.CONSTRUCTING)
{
FMLLog.severe("There is a severe problem with %s - it appears not to have constructed correctly", mc.getModId());
if (state != LoaderState.CONSTRUCTING)
{
this.errorOccurred(mc, new RuntimeException());
}
}
}
return builder.build();
}