List of usage examples for com.google.common.collect Maps newTreeMap
public static <K extends Comparable, V> TreeMap<K, V> newTreeMap()
From source file:com.proofpoint.bootstrap.Bootstrap.java
public Injector initialize() throws Exception { Logging logging = new Logging(); Thread.currentThread().setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override//from ww w . ja va 2 s. c om public void uncaughtException(Thread t, Throwable e) { log.error(e, "Uncaught exception in thread %s", t.getName()); } }); // initialize configuration log.info("Loading configuration"); ConfigurationLoader loader = new ConfigurationLoader(); Map<String, String> configFileProperties = Collections.emptyMap(); String configFile = System.getProperty("config"); if (configFile != null) { configFileProperties = loader.loadPropertiesFrom(configFile); } SortedMap<String, String> properties = Maps.newTreeMap(); properties.putAll(configFileProperties); properties.putAll(loader.getSystemProperties()); properties = ImmutableSortedMap.copyOf(properties); ConfigurationFactory configurationFactory = new ConfigurationFactory(properties); // initialize logging log.info("Initializing logging"); LoggingConfiguration configuration = configurationFactory.build(LoggingConfiguration.class); logging.initialize(configuration); // create warning logger now that we have logging initialized final WarningsMonitor warningsMonitor = new WarningsMonitor() { @Override public void onWarning(String message) { log.warn(message); } }; // Validate configuration ConfigurationValidator configurationValidator = new ConfigurationValidator(configurationFactory, warningsMonitor); List<Message> messages = configurationValidator.validate(modules); // at this point all config file properties should be used // so we can calculate the unused properties final TreeMap<String, String> unusedProperties = Maps.newTreeMap(); unusedProperties.putAll(configFileProperties); unusedProperties.keySet().removeAll(configurationFactory.getUsedProperties()); // system modules Builder<Module> moduleList = ImmutableList.builder(); moduleList.add(new LifeCycleModule()); moduleList.add(new ConfigurationModule(configurationFactory)); if (!messages.isEmpty()) { moduleList.add(new ValidationErrorModule(messages)); } moduleList.add(new Module() { @Override public void configure(Binder binder) { binder.bind(WarningsMonitor.class).toInstance(warningsMonitor); } }); moduleList.add(new Module() { @Override public void configure(Binder binder) { binder.disableCircularProxies(); binder.requireExplicitBindings(); } }); // todo this should be part of the ValidationErrorModule if (strictConfig) { moduleList.add(new Module() { @Override public void configure(Binder binder) { for (Entry<String, String> unusedProperty : unusedProperties.entrySet()) { binder.addError("Configuration property '%s=%s' was not used", unusedProperty.getKey(), unusedProperty.getValue()); } } }); } moduleList.add(modules); // create the injector Injector injector = Guice.createInjector(Stage.PRODUCTION, moduleList.build()); // Create the life-cycle manager LifeCycleManager lifeCycleManager = injector.getInstance(LifeCycleManager.class); // Log effective configuration logConfiguration(configurationFactory, unusedProperties); // Log managed objects logJMX(injector); // Start services if (lifeCycleManager.size() > 0) { lifeCycleManager.start(); } return injector; }
From source file:lombok.ast.grammar.Source.java
public void clear() { nodes = Lists.newArrayList();//from ww w. j a v a 2 s. co m problems = Lists.newArrayList(); comments = Lists.newArrayList(); lineEndings = ImmutableList.of(); parsed = false; parsingResult = null; positionDeltas = Maps.newTreeMap(); registeredComments = new MapMaker().weakKeys().makeMap(); registeredStructures = new MapMaker().weakKeys().makeMap(); cachedSourceStructures = null; }
From source file:things.thing.ThingUtils.java
public Map<String, JsonSchema> getRegisteredTypeSchemata() { if (schemaMap == null) { Map<String, JsonSchema> temp = Maps.newTreeMap(); for (String type : tr.getAllTypes()) { Class typeClass = tr.getTypeClass(type); SchemaFactoryWrapper visitor = new SchemaFactoryWrapper(); try { objectMapper.acceptJsonFormatVisitor(objectMapper.constructType(typeClass), visitor); } catch (JsonMappingException e) { throw new TypeRuntimeException("Can't get schema for type: " + type, type, e); }/*from w w w . jav a 2 s. co m*/ JsonSchema jsonSchema = visitor.finalSchema(); temp.put(type, jsonSchema); } schemaMap = ImmutableMap.copyOf(temp); } return schemaMap; }
From source file:com.jivesoftware.sdk.service.instance.action.InstanceRegisterAction.java
@Nonnull public SortedMap<String, String> toSortedMap() { // Encode the client-secret String encodedClientSecret = (clientSecret != null) ? DigestUtils.sha256Hex(clientSecret) : clientSecret; SortedMap<String, String> sortedMap = Maps.newTreeMap(); sortedMap.put(CLIENT_ID, clientId);//from ww w . j a v a 2 s .c om sortedMap.put(CLIENT_SECRET, encodedClientSecret); sortedMap.put(CODE, code); sortedMap.put(JIVE_SIGNATURE_URL, jiveSignatureURL); sortedMap.put(JIVE_URL, jiveUrl); sortedMap.put(SCOPE, scope); sortedMap.put(TENANT_ID, tenantId); sortedMap.put(TIMESTAMP, timestamp); return sortedMap; }
From source file:ec.nbdemetra.ui.demo.ComponentsDemo.java
private static SortedMap<Id, Component> lookupComponents() { TreeMap<Id, Component> result = Maps.newTreeMap(); for (DemoComponentFactory o : Lookup.getDefault().lookupAll(DemoComponentFactory.class)) { for (Entry<Id, Callable<Component>> e : o.getComponents().entrySet()) { result.put(e.getKey(), configure(create(e.getValue()))); }/*from w w w.j av a2 s .com*/ } return result; }
From source file:com.google.auto.value.processor.TemplateVars.java
private Map<String, Object> toVars() { Map<String, Object> vars = Maps.newTreeMap(); for (Field field : fields) { Object value = fieldValue(field, this); if (value == null) { throw new IllegalArgumentException("Field cannot be null (was it set?): " + field); }//w w w .j a va 2s . c om Object old = vars.put(field.getName(), value); if (old != null) { throw new IllegalArgumentException("Two fields called " + field.getName() + "?!"); } } return ImmutableMap.copyOf(vars); }
From source file:me.philnate.textmanager.updates.Updater.java
static TreeMap<Version, Class<? extends Update>> createUpdateList(String packageName) { final TreeMap<Version, Class<? extends Update>> updates = Maps.newTreeMap(); final TypeReporter reporter = new TypeReporter() { @SuppressWarnings("unchecked") @Override//from www . j av a 2 s.co m public Class<? extends Annotation>[] annotations() { return new Class[] { UpdateScript.class }; } @SuppressWarnings("unchecked") @Override public void reportTypeAnnotation(Class<? extends Annotation> annotation, String className) { Class<? extends Update> clazz; try { clazz = (Class<? extends Update>) Updater.class.getClassLoader().loadClass(className); updates.put(new Version(clazz.getAnnotation(UpdateScript.class).UpdatesVersion()), clazz); } catch (ClassNotFoundException e) { LOG.error("Found annotated class, but could not load it " + className, e); } } }; final AnnotationDetector cf = new AnnotationDetector(reporter); try { // load updates cf.detect(packageName); } catch (IOException e) { LOG.error("An error occured while collecting Updates", e); } return updates; }
From source file:com.netflix.ice.basic.BasicTagGroupManager.java
private TreeMap<Long, Collection<TagGroup>> removeResourceGroups( TreeMap<Long, Collection<TagGroup>> tagGroups) { TreeMap<Long, Collection<TagGroup>> result = Maps.newTreeMap(); for (Long key : tagGroups.keySet()) { Collection<TagGroup> from = tagGroups.get(key); Set<TagGroup> to = Sets.newHashSet(); for (TagGroup tagGroup : from) { if (tagGroup.resourceGroup != null) to.add(new TagGroup(tagGroup.account, tagGroup.region, tagGroup.zone, tagGroup.product, tagGroup.operation, tagGroup.usageType, null)); else//from ww w . ja v a 2 s . co m to.add(tagGroup); } result.put(key, to); } return result; }
From source file:com.google.gdt.eclipse.designer.gxt.model.widgets.UntypedEventsRootProcessor.java
private void contributeContextMenu(IMenuManager manager, final ComponentInfo component) { Map<String, MenuManagerEx> eventManagers = Maps.newTreeMap(); for (final EventDescription description : getEventDescriptions(component)) { // prepare MenuManager for event MenuManagerEx eventManager;//from w w w . ja va2 s. c o m { String event = description.getEvent(); eventManager = eventManagers.get(event); if (eventManager == null) { eventManager = new MenuManagerEx(event); eventManager.setImage(EventsPropertyUtils.LISTENER_INTERFACE_IMAGE); eventManagers.put(event, eventManager); manager.appendToGroup(IContextMenuConstants.GROUP_EVENTS2, eventManager); } } // add specific name Action action = new Action() { @Override public void runWithEvent(Event event) { if ((event.stateMask & SWT.CTRL) != 0) { removeListener(component, description); } else { openListener(component, description); } } }; { String text = description.getName(); MethodInvocation invocation = getInvocation(component, description); if (invocation != null) { int line = 1 + component.getEditor().getLineNumber(invocation.getStartPosition()); text += "\tline " + line; } action.setText(text); } action.setImageDescriptor(EventsPropertyUtils.LISTENER_METHOD_IMAGE_DESCRIPTOR); eventManager.add(action); } }
From source file:com.opengamma.bbg.EHCachingReferenceDataProvider.java
@Override protected Map<String, PerSecurityReferenceDataResult> loadCachedResults(Set<String> securityKeys) { Map<String, PerSecurityReferenceDataResult> result = Maps.newTreeMap(); FudgeSerializer serializer = new FudgeSerializer(getFudgeContext()); // REVIEW kirk 2009-10-23 -- Candidate for scatter/gather for performance. for (String securityKey : securityKeys) { PerSecurityReferenceDataResult cachedResult = loadStateFromCache(serializer, securityKey); if (cachedResult != null) { result.put(securityKey, cachedResult); }//from w ww.ja v a 2 s .com } return result; }