List of usage examples for com.google.common.collect ImmutableMap get
V get(Object key);
From source file:org.apache.druid.indexing.overlord.setup.JavaScriptWorkerSelectStrategy.java
@Override public ImmutableWorkerInfo findWorkerForTask(WorkerTaskRunnerConfig config, ImmutableMap<String, ImmutableWorkerInfo> zkWorkers, Task task) { fnSelector = fnSelector == null ? compileSelectorFunction() : fnSelector; String worker = fnSelector.apply(config, zkWorkers, task); return worker == null ? null : zkWorkers.get(worker); }
From source file:org.spongepowered.granite.mixin.block.state.MixinBlockState.java
@Override @SuppressWarnings("unchecked") public Optional<? extends Comparable<?>> getPropertyValue(String name) { ImmutableMap<IProperty, Comparable<?>> properties = ((IBlockState) this).getProperties(); for (IProperty property : properties.keySet()) { if (property.getName().equals(name)) { return Optional.fromNullable(properties.get(property)); }//from w ww . j a v a2 s. c om } return Optional.absent(); }
From source file:com.baasbox.security.SessionTokenProvider.java
private boolean isExpired(String token) { ImmutableMap<SessionKeys, ? extends Object> info = sessions.get(token); if (info == null) return true; if (expiresInMilliseconds != 0 && (new Date()).getTime() > (Long) info.get(SessionKeys.EXPIRE_TIME)) { removeSession(token);/* w ww .ja v a 2 s .co m*/ return true; } return false; }
From source file:com.google.jimfs.PosixAttributeProvider.java
@Override public PosixFileAttributeView view(FileLookup lookup, ImmutableMap<String, FileAttributeView> inheritedViews) { return new View(lookup, (BasicFileAttributeView) inheritedViews.get("basic"), (FileOwnerAttributeView) inheritedViews.get("owner")); }
From source file:com.google.caliper.runner.config.CaliperConfig.java
/** Returns the configuration for the device with the given name. */ public DeviceConfig getDeviceConfig(String deviceName) { ImmutableMap<String, String> devices = subgroupMap(properties, "device"); ImmutableMap<String, String> device = subgroupMap(devices, deviceName); String deviceTypeField = device.get("type"); if (deviceTypeField == null) { throw new InvalidConfigurationException("Missing configuration field: device." + deviceName + ".type"); }//from w w w .j a v a 2 s. c o m return DeviceConfig.builder().name(deviceName).type(DeviceType.of(deviceTypeField)) .options(subgroupMap(device, "options")).build(); }
From source file:com.facebook.buck.parser.AbstractParserConfig.java
/** * A (possibly empty) sequence of paths to files that should be included by default when * evaluating a build file.//from w w w . j a va2s .c o m */ @Value.Lazy public Iterable<String> getDefaultIncludes() { ImmutableMap<String, String> entries = getDelegate().getEntriesForSection(BUILDFILE_SECTION_NAME); String includes = Strings.nullToEmpty(entries.get("includes")); return Splitter.on(' ').trimResults().omitEmptyStrings().split(includes); }
From source file:org.onos.yangtools.binding.data.codec.impl.LazyDataObject.java
private Object getAugmentationImpl(final Class<?> cls) { final ImmutableMap<Class<? extends Augmentation<?>>, Augmentation<?>> aug = cachedAugmentations; if (aug != null) { return aug.get(cls); }//from w ww .ja v a 2s.c o m Preconditions.checkNotNull(cls, "Supplied augmentation must not be null."); @SuppressWarnings({ "unchecked", "rawtypes" }) final Optional<DataContainerCodecContext<?, ?>> augCtx = context.possibleStreamChild((Class) cls); if (augCtx.isPresent()) { final Optional<NormalizedNode<?, ?>> augData = data.getChild(augCtx.get().getDomPathArgument()); if (augData.isPresent()) { return augCtx.get().deserialize(augData.get()); } } return null; }
From source file:io.awacs.server.DefaultPlugins.java
@Override public void init(Configuration configuration) throws InitializationException { String[] pluginNames = configuration.getString(Configurations.PLUGIN_PREFIX).trim().split(","); for (String pluginName : pluginNames) { try {/*from ww w.j a va2s . c o m*/ logger.info("Plugin {} configuration found.", pluginName); ImmutableMap<String, String> pluginConfig = configuration .getSubProperties(Configurations.PLUGIN_PREFIX + "." + pluginName + "."); String handlerClassName = pluginConfig.get(Configurations.HANDLER_CLASS); String keyType = pluginConfig.get(Configurations.KEY_CLASS); String keyValue = pluginConfig.get(Configurations.KEY_VALUE); String pluginClassName = pluginConfig.get(Configurations.PLUGIN_CLASS); String pluginPathRoot = Configurations.getPluginPath(); String relativePath = "/awacs-" + pluginName + "-plugin.jar"; String pluginPath = pluginPathRoot + relativePath; String fileHash = Files.hash(new File(pluginPath), Hashing.sha1()).toString(); PluginDescriptor descriptor = new PluginDescriptor().setPluginClass(pluginClassName) .setHash(fileHash).setName(pluginName).setKeyClass(keyType).setKeyValue(keyValue) .setDownloadUrl(relativePath); Class<?> clazz = Class.forName(handlerClassName); PluginHandler handler = (PluginHandler) clazz.newInstance(); handler.init(new Configuration(pluginConfig)); if (handler instanceof RepositoriesAware) { ((RepositoriesAware) handler).setContext(repositories); } if (clazz.isAnnotationPresent(EnableInjection.class)) { List<Field> waitForInject = Stream.of(clazz.getDeclaredFields()).filter( f -> f.isAnnotationPresent(Resource.class) || f.isAnnotationPresent(Injection.class)) .collect(Collectors.toList()); for (Field f : waitForInject) { f.setAccessible(true); if (f.get(handler) == null) { String name; if (f.isAnnotationPresent(Resource.class)) { Resource r = f.getDeclaredAnnotation(Resource.class); name = r.name(); } else { Injection i = f.getDeclaredAnnotation(Injection.class); name = i.name(); } Object repo = repositories.lookup(name, f.getType()); f.set(handler, repo); logger.debug("Inject repository {} to plugin handler {}", repo, handler); } } } Key<?> k = Key.getKey(keyType, keyValue); handlers.put(k, handler); descriptors.put(k, descriptor); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IOException | NoSuchKeyTypeException | RepositoryNotFoundException e) { e.printStackTrace(); throw new InitializationException(); } } }
From source file:com.epam.dlab.configuration.LoggingConfigurationFactory.java
/** Set the list of logging levels for appenders. */ @JsonProperty//from w ww .j a v a 2 s. c o m public void setLoggers(ImmutableMap<String, JsonNode> loggers) throws InitializationException { ImmutableMap.Builder<String, Level> levels = new ImmutableMap.Builder<String, Level>(); for (String key : loggers.keySet()) { JsonNode node = loggers.get(key); levels.put(key, toLevel(node.asText())); } this.loggers = levels.build(); }
From source file:uk.q3c.krail.core.navigate.sitemap.UserSitemapCopyExtension.java
/** * All the standard pages are always copied, even though they may not appear in the main uriMap. The standard pages are often used for comparison in * things/*from w ww.j a va 2 s. c o m*/ * like {@link LoginNavigationRule}s, so need always to be available, even though they are not necessarily displayed in navigation components */ private void copyStandardPages() { log.debug("copying standard pages"); ImmutableMap<StandardPageKey, MasterSitemapNode> sourcePages = masterSitemap.getStandardPages(); Collator collator = Collator.getInstance(currentLocale.getLocale()); for (StandardPageKey spk : sourcePages.keySet()) { MasterSitemapNode masterNode = sourcePages.get(spk); UserSitemapNode userNode = new UserSitemapNode(masterNode); userNode.setLabel(translate.from(masterNode.getLabelKey())); userNode.setCollationKey(collator.getCollationKey(userNode.getLabel())); userSitemap.addStandardPage(userNode, masterSitemap.uri(masterNode)); } }