List of usage examples for com.google.common.collect ImmutableBiMap of
@SuppressWarnings("unchecked") public static <K, V> ImmutableBiMap<K, V> of()
From source file:google.registry.tools.server.ListObjectsAction.java
/** * Returns an {@link ImmutableBiMap} that maps any field name aliases to the actual field names. * * <p>Users can select aliased fields for display using either the original name or the alias. By * default, aliased fields will use the alias name as the header instead of the original name. */// w ww .j a va 2s. co m ImmutableBiMap<String, String> getFieldAliases() { return ImmutableBiMap.of(); }
From source file:net.minecrell.quartz.launch.mappings.Mappings.java
protected Mappings(List<ClassNode> mappingClasses) { requireNonNull(mappingClasses, "mappingClasses"); if (mappingClasses.isEmpty()) { this.classes = ImmutableBiMap.of(); this.methods = ImmutableTable.of(); this.fields = ImmutableTable.of(); this.constructors = ImmutableMultimap.of(); this.accessMappings = ImmutableTable.of(); return;/*from ww w.j a v a 2s . c o m*/ } ImmutableBiMap.Builder<String, String> classes = ImmutableBiMap.builder(); for (ClassNode classNode : mappingClasses) { ParsedAnnotation annotation = MappingsParser.getAnnotation(classNode, MAPPING); checkState(annotation != null, "Class %s is missing the @Mapping annotation", classNode.name); String mapping = annotation.getString("value", ""); if (!mapping.isEmpty()) { classes.put(mapping, classNode.name); } } this.classes = classes.build(); // We need to remap the descriptors of the fields and methods, use ASM for convenience Remapper remapper = new Remapper() { @Override public String map(String className) { return unmap(className); } }; // Load field, method and access mappings ImmutableTable.Builder<String, String, String> methods = ImmutableTable.builder(); ImmutableTable.Builder<String, String, String> fields = ImmutableTable.builder(); ImmutableMultimap.Builder<String, MethodNode> constructors = ImmutableMultimap.builder(); ImmutableTable.Builder<String, String, AccessMapping> accessMappings = ImmutableTable.builder(); for (ClassNode classNode : mappingClasses) { String className = classNode.name.replace('/', '.'); String internalName = unmap(classNode.name); ParsedAnnotation annotation = MappingsParser.getAnnotation(classNode, ACCESSIBLE); if (annotation != null) { accessMappings.put(className, "", AccessMapping.of(classNode)); } for (MethodNode methodNode : classNode.methods) { Map<String, ParsedAnnotation> annotations = MappingsParser.getAnnotations(methodNode); annotation = annotations.get(CONSTRUCTOR); if (annotation != null) { // Generate constructor call code Methods.visitConstructor(methodNode, classNode.name); constructors.put(className, methodNode); continue; } // TODO: Validation annotation = annotations.get(MAPPING); if (annotation != null) { String mapping = annotation.getString("value", ""); if (!mapping.isEmpty()) { methods.put(internalName, mapping + remapper.mapMethodDesc(methodNode.desc), methodNode.name); } } annotation = annotations.get(ACCESSIBLE); if (annotation != null) { accessMappings.put(className, methodNode.name + methodNode.desc, AccessMapping.of(methodNode)); } } for (FieldNode fieldNode : classNode.fields) { Map<String, ParsedAnnotation> annotations = MappingsParser.getAnnotations(fieldNode); // TODO: Validation annotation = annotations.get(MAPPING); if (annotation != null) { String mapping = annotation.getString("value", ""); if (!mapping.isEmpty()) { fields.put(internalName, mapping + ':' + remapper.mapDesc(fieldNode.desc), fieldNode.name); } } annotation = annotations.get(ACCESSIBLE); if (annotation != null) { accessMappings.put(className, fieldNode.name, AccessMapping.of(fieldNode)); } } } this.methods = methods.build(); this.fields = fields.build(); this.constructors = constructors.build(); this.accessMappings = accessMappings.build(); }
From source file:net.shibboleth.idp.consent.storage.impl.ConsentSerializer.java
/** Constructor. */ public ConsentSerializer() { generatorFactory = Json.createGeneratorFactory(null); readerFactory = Json.createReaderFactory(null); symbolics = ImmutableBiMap.of(); }
From source file:net.minecrell.workbench.tools.mapping.BaseMappings.java
public ClassMappings apply(ClassMappings mappings) { return new ClassMappings(context, ImmutableBiMap.of(), apply(mappings.getFields(), this.fields, null), apply(mappings.getMethods(), this.methods, this::applyParameters)); }
From source file:com.facebook.buck.cxx.toolchain.DefaultCxxPlatforms.java
public static CxxPlatform build(Platform platform, CxxBuckConfig config) { String sharedLibraryExtension; String sharedLibraryVersionedExtensionFormat; String staticLibraryExtension; String objectFileExtension;/*from w w w.j a va 2s . co m*/ Path defaultCFrontend; Path defaultCxxFrontend; Path defaultLinker; LinkerProvider.Type linkerType; Archiver archiver; DebugPathSanitizer compilerSanitizer; Optional<String> binaryExtension; ImmutableMap<String, String> env = config.getEnvironment(); Optional<CxxToolProvider.Type> defaultToolType = Optional.empty(); Optional<ToolProvider> ranlib; PicType picTypeForSharedLinking; switch (platform) { case LINUX: sharedLibraryExtension = "so"; sharedLibraryVersionedExtensionFormat = "so.%s"; staticLibraryExtension = "a"; objectFileExtension = "o"; defaultCFrontend = getExecutablePath("gcc", DEFAULT_C_FRONTEND, env); defaultCxxFrontend = getExecutablePath("g++", DEFAULT_CXX_FRONTEND, env); defaultLinker = defaultCxxFrontend; linkerType = LinkerProvider.Type.GNU; archiver = new GnuArchiver(getHashedFileTool(config, "ar", DEFAULT_AR, env)); compilerSanitizer = new PrefixMapDebugPathSanitizer(".", ImmutableBiMap.of()); binaryExtension = Optional.empty(); ranlib = Optional.of( new ConstantToolProvider(getHashedFileTool(config, DEFAULT_UNIX_RANLIB, DEFAULT_RANLIB, env))); picTypeForSharedLinking = PicType.PIC; break; case MACOS: sharedLibraryExtension = "dylib"; sharedLibraryVersionedExtensionFormat = ".%s.dylib"; staticLibraryExtension = "a"; objectFileExtension = "o"; defaultCFrontend = getExecutablePath("clang", DEFAULT_OSX_C_FRONTEND, env); defaultCxxFrontend = getExecutablePath("clang++", DEFAULT_OSX_CXX_FRONTEND, env); defaultLinker = defaultCxxFrontend; linkerType = LinkerProvider.Type.DARWIN; archiver = new BsdArchiver(getHashedFileTool(config, "ar", DEFAULT_AR, env)); compilerSanitizer = new PrefixMapDebugPathSanitizer(".", ImmutableBiMap.of()); binaryExtension = Optional.empty(); ranlib = Optional.of( new ConstantToolProvider(getHashedFileTool(config, DEFAULT_UNIX_RANLIB, DEFAULT_RANLIB, env))); picTypeForSharedLinking = PicType.PIC; break; case WINDOWS: sharedLibraryExtension = "dll"; sharedLibraryVersionedExtensionFormat = "dll"; staticLibraryExtension = "lib"; objectFileExtension = "obj"; defaultCFrontend = getExecutablePath(DEFAULT_WINDOWS_CXX_FRONTEND, Paths.get(DEFAULT_WINDOWS_CXX_FRONTEND), env); defaultCxxFrontend = getExecutablePath(DEFAULT_WINDOWS_CXX_FRONTEND, Paths.get(DEFAULT_WINDOWS_CXX_FRONTEND), env); defaultLinker = getExecutablePath(DEFAULT_WINDOWS_LINK, Paths.get(DEFAULT_WINDOWS_LINK), env); linkerType = LinkerProvider.Type.WINDOWS; archiver = new WindowsArchiver( getHashedFileTool(config, DEFAULT_WINDOWS_LIB, Paths.get(DEFAULT_WINDOWS_LIB), env)); compilerSanitizer = new PrefixMapDebugPathSanitizer(".", ImmutableBiMap.of()); binaryExtension = Optional.of("exe"); defaultToolType = Optional.of(CxxToolProvider.Type.WINDOWS); ranlib = Optional.empty(); picTypeForSharedLinking = PicType.PDC; break; case FREEBSD: sharedLibraryExtension = "so"; sharedLibraryVersionedExtensionFormat = "so.%s"; staticLibraryExtension = "a"; objectFileExtension = "o"; defaultCFrontend = getExecutablePath("gcc", DEFAULT_C_FRONTEND, env); defaultCxxFrontend = getExecutablePath("g++", DEFAULT_CXX_FRONTEND, env); defaultLinker = defaultCxxFrontend; linkerType = LinkerProvider.Type.GNU; archiver = new BsdArchiver(getHashedFileTool(config, "ar", DEFAULT_AR, env)); compilerSanitizer = new PrefixMapDebugPathSanitizer(".", ImmutableBiMap.of()); binaryExtension = Optional.empty(); ranlib = Optional.of( new ConstantToolProvider(getHashedFileTool(config, DEFAULT_UNIX_RANLIB, DEFAULT_RANLIB, env))); picTypeForSharedLinking = PicType.PIC; break; // $CASES-OMITTED$ default: throw new RuntimeException(String.format("Unsupported platform: %s", platform)); } // These are wrapped behind suppliers because config.getSourcePath() verifies that the path // exists and we only want to do that verification if the tool is actually needed. Supplier<PathSourcePath> cFrontendPath = MoreSuppliers .memoize(() -> config.getSourcePath(defaultCFrontend)); ToolProvider defaultCFrontendSupplier = new ConstantToolProvider(getToolchainTool(cFrontendPath)); Supplier<PathSourcePath> cxxFrontendPath = MoreSuppliers .memoize(() -> config.getSourcePath(defaultCxxFrontend)); ToolProvider defaultCxxFrontendSupplier = new ConstantToolProvider(getToolchainTool(cxxFrontendPath)); Optional<Type> finalDefaultToolType = defaultToolType; Supplier<Type> cFrontendType = MoreSuppliers.memoize(() -> finalDefaultToolType .orElseGet(() -> CxxToolTypeInferer.getTypeFromPath(cFrontendPath.get()))); Supplier<Type> cxxFrontendType = MoreSuppliers.memoize(() -> finalDefaultToolType .orElseGet(() -> CxxToolTypeInferer.getTypeFromPath(cxxFrontendPath.get()))); PreprocessorProvider aspp = new PreprocessorProvider(defaultCFrontendSupplier, cFrontendType); CompilerProvider as = new CompilerProvider(defaultCFrontendSupplier, cFrontendType, config.getUseDetailedUntrackedHeaderMessages()); PreprocessorProvider cpp = new PreprocessorProvider(defaultCFrontendSupplier, cFrontendType); CompilerProvider cc = new CompilerProvider(defaultCFrontendSupplier, cFrontendType, config.getUseDetailedUntrackedHeaderMessages()); PreprocessorProvider cxxpp = new PreprocessorProvider(defaultCxxFrontendSupplier, cxxFrontendType); CompilerProvider cxx = new CompilerProvider(defaultCxxFrontendSupplier, cxxFrontendType, config.getUseDetailedUntrackedHeaderMessages()); return CxxPlatforms.build(FLAVOR, platform, config, as, aspp, cc, cxx, cpp, cxxpp, new DefaultLinkerProvider(linkerType, new ConstantToolProvider(getToolchainTool(() -> config.getSourcePath(defaultLinker))), config.shouldCacheLinks()), ImmutableList.of(), ImmutableMultimap.of(), getHashedFileTool(config, "strip", DEFAULT_STRIP, env), ArchiverProvider.from(archiver), ArchiveContents.NORMAL, ranlib, new PosixNmSymbolNameTool(getHashedFileTool(config, "nm", DEFAULT_NM, env)), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), ImmutableList.of(), sharedLibraryExtension, sharedLibraryVersionedExtensionFormat, staticLibraryExtension, objectFileExtension, compilerSanitizer, new MungingDebugPathSanitizer(config.getDebugPathSanitizerLimit(), File.separatorChar, Paths.get("."), ImmutableBiMap.of()), ImmutableMap.of(), binaryExtension, config.getHeaderVerificationOrIgnore(), picTypeForSharedLinking); }
From source file:com.github.rinde.rinsim.core.model.comm.CommModel.java
CommModel(RandomGenerator rng, Builder b) { defaultReliability = b.defaultReliability(); defaultMaxRange = b.defaultMaxRange(); usersHasChanged = false;/*from w ww . jav a2 s . c om*/ usersDevices = Maps.synchronizedBiMap(LinkedHashBiMap.<CommUser, CommDevice>create()); unregisteredUsersDevices = LinkedHashBiMap.<CommUser, CommDevice>create(); usersDevicesSnapshot = ImmutableBiMap.of(); eventDispatcher = new EventDispatcher(EventTypes.values()); randomGenerator = rng; }
From source file:com.addthis.codec.plugins.PluginMap.java
private PluginMap() { config = ConfigFactory.empty();/* ww w . ja v a 2s .c om*/ map = ImmutableBiMap.of(); aliases = Collections.emptyMap(); inlinedAliases = Collections.emptySet(); classField = "class"; category = "unknown"; baseClass = null; }
From source file:com.google.devtools.build.lib.skyframe.ToolchainUtil.java
@Nullable private static ImmutableBiMap<Label, Label> resolveToolchainLabels(Environment env, Set<Label> requiredToolchains, BuildConfiguration configuration) throws InterruptedException, ToolchainContextException { // If there are no required toolchains, bail out early. if (requiredToolchains.isEmpty()) { return ImmutableBiMap.of(); }// ww w .ja va 2 s . c om // Load the execution and target platforms for the current configuration. PlatformDescriptors platforms = loadPlatformDescriptors(env, configuration); if (platforms == null) { return null; } // Find the toolchains for the required toolchain types. List<SkyKey> registeredToolchainKeys = new ArrayList<>(); for (Label toolchainType : requiredToolchains) { registeredToolchainKeys.add(ToolchainResolutionValue.key(configuration, toolchainType, platforms.targetPlatform(), platforms.execPlatform())); } Map<SkyKey, ValueOrException4<NoToolchainFoundException, ConfiguredValueCreationException, InvalidToolchainLabelException, EvalException>> results = env .getValuesOrThrow(registeredToolchainKeys, NoToolchainFoundException.class, ConfiguredValueCreationException.class, InvalidToolchainLabelException.class, EvalException.class); boolean valuesMissing = false; // Load the toolchains. ImmutableBiMap.Builder<Label, Label> builder = new ImmutableBiMap.Builder<>(); List<Label> missingToolchains = new ArrayList<>(); for (Map.Entry<SkyKey, ValueOrException4<NoToolchainFoundException, ConfiguredValueCreationException, InvalidToolchainLabelException, EvalException>> entry : results .entrySet()) { try { Label requiredToolchainType = ((ToolchainResolutionKey) entry.getKey().argument()).toolchainType(); ValueOrException4<NoToolchainFoundException, ConfiguredValueCreationException, InvalidToolchainLabelException, EvalException> valueOrException = entry .getValue(); if (valueOrException.get() == null) { valuesMissing = true; } else { Label toolchainLabel = ((ToolchainResolutionValue) valueOrException.get()).toolchainLabel(); builder.put(requiredToolchainType, toolchainLabel); } } catch (NoToolchainFoundException e) { // Save the missing type and continue looping to check for more. missingToolchains.add(e.missingToolchainType()); } catch (ConfiguredValueCreationException e) { throw new ToolchainContextException(e); } catch (InvalidToolchainLabelException e) { throw new ToolchainContextException(e); } catch (EvalException e) { throw new ToolchainContextException(e); } } if (!missingToolchains.isEmpty()) { throw new ToolchainContextException(new UnresolvedToolchainsException(missingToolchains)); } if (valuesMissing) { return null; } return builder.build(); }
From source file:net.minecraftforge.fml.common.registry.GameData.java
@SuppressWarnings("unchecked") <T> BiMap<String, T> getPersistentSubstitutionMap(Class<T> type) { if (type.equals(Item.class)) { return (BiMap<String, T>) itemSubstitutions; } else if (type.equals(Block.class)) { return (BiMap<String, T>) blockSubstitutions; } else {// ww w.ja v a2s .co m return ImmutableBiMap.of(); } }