Java Code Examples for com.google.common.collect.Maps#newLinkedHashMap()
The following examples show how to use
com.google.common.collect.Maps#newLinkedHashMap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShiroConfig.java From mysiteforme with Apache License 2.0 | 6 votes |
@Bean(name = "shiroFilter") public ShiroFilterFactoryBean shiroFilterFactoryBean(@Qualifier("authRealm")AuthRealm authRealm){ ShiroFilterFactoryBean bean = new ShiroFilterFactoryBean(); bean.setSecurityManager(securityManager(authRealm)); bean.setSuccessUrl("/index"); bean.setLoginUrl("/login"); Map<String,Filter> map = Maps.newHashMap(); map.put("authc",new CaptchaFormAuthenticationFilter()); bean.setFilters(map); //配置访问权限 LinkedHashMap<String, String> filterChainDefinitionMap = Maps.newLinkedHashMap(); filterChainDefinitionMap.put("/static/**","anon"); filterChainDefinitionMap.put("/showBlog/**","anon"); filterChainDefinitionMap.put("/blog/**","anon"); filterChainDefinitionMap.put("/login/main","anon"); filterChainDefinitionMap.put("/genCaptcha","anon"); filterChainDefinitionMap.put("/systemLogout","authc"); filterChainDefinitionMap.put("/**","authc"); bean.setFilterChainDefinitionMap(filterChainDefinitionMap); return bean; }
Example 2
Source File: SiegeRaceCounter.java From aion-germany with GNU General Public License v3.0 | 6 votes |
protected <K> Map<K, Long> getOrderedCounterMap(Map<K, AtomicLong> unorderedMap) { if (GenericValidator.isBlankOrNull(unorderedMap)) { return Collections.emptyMap(); } LinkedList<Map.Entry<K, AtomicLong>> tempList = Lists.newLinkedList(unorderedMap.entrySet()); Collections.sort(tempList, new Comparator<Map.Entry<K, AtomicLong>>() { @Override public int compare(Map.Entry<K, AtomicLong> o1, Map.Entry<K, AtomicLong> o2) { return new Long(o2.getValue().get()).compareTo(o1.getValue().get()); } }); Map<K, Long> result = Maps.newLinkedHashMap(); for (Map.Entry<K, AtomicLong> entry : tempList) { if (entry.getValue().get() > 0) { result.put(entry.getKey(), entry.getValue().get()); } } return result; }
Example 3
Source File: FetchClusterRequestHandler.java From joyqueue with Apache License 2.0 | 6 votes |
protected TopicPartitionGroup convertTopicPartitionGroup(Connection connection, PartitionGroup partitionGroup, Map<Integer, BrokerNode> brokers) { Map<Short, TopicPartition> partitions = Maps.newLinkedHashMap(); Broker leaderBroker = partitionGroup.getLeaderBroker(); if (leaderBroker != null) { DataCenter brokerDataCenter = clusterNameService.getNameService().getDataCenter(leaderBroker.getIp()); brokers.put(partitionGroup.getLeader(), BrokerNodeConverter.convertBrokerNode(leaderBroker, brokerDataCenter, connection.getRegion())); } for (Short partition : partitionGroup.getPartitions()) { partitions.put(partition, convertTopicPartition(partitionGroup, partition)); } TopicPartitionGroup result = new TopicPartitionGroup(); result.setId(partitionGroup.getGroup()); result.setLeader(partitionGroup.getLeader()); result.setPartitions(partitions); return result; }
Example 4
Source File: Payload.java From emodb with Apache License 2.0 | 5 votes |
@Override public String toString() { Map<String, Object> map = Maps.newLinkedHashMap(); map.put("serviceUrl", _serviceUrl); map.put("adminUrl", _adminUrl); if (!_extensions.isEmpty()) { map.put("extensions", _extensions); } return JsonHelper.asJson(map); }
Example 5
Source File: IndexedSourceAdapter.java From yql-plus with Apache License 2.0 | 5 votes |
private static <T> Map<IndexKey, T> createIndexMap(Map<IndexDescriptor, T> methodMap) { Map<IndexKey, T> indexes = Maps.newLinkedHashMap(); for (Map.Entry<IndexDescriptor, T> e : methodMap.entrySet()) { indexes.put(IndexKey.of(e.getKey().getColumnNames()), e.getValue()); } return indexes; }
Example 6
Source File: ContextPDAProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected Set<ParserRule> findRuleCallsToExclude(Pda<ISerState, RuleCall> pda, Map<ParserRule, Integer> indexedRules) { Map<ParserRule, Integer> result = Maps.newLinkedHashMap(); for (ISerState s : nfaUtil.collect(pda)) { ParserRule pr = getFilterableRule(s); if (pr != null) { Integer integer = result.get(pr); result.put(pr, integer == null ? 1 : integer + 1); } } Iterator<Integer> it = result.values().iterator(); while (it.hasNext()) { if (it.next() > 1) { it.remove(); } } nfaUtil.findCycles(pda, new IAcceptor<List<ISerState>>() { @Override public void accept(List<ISerState> states) { ParserRule candidate = null; Integer candiateIndex = Integer.MAX_VALUE; for (ISerState state : states) { ParserRule rule = getFilterableRule(state); if (rule != null) { Integer index = indexedRules.get(rule); if (candiateIndex > index) { candidate = rule; candiateIndex = index; } } } if (candidate != null) { result.remove(candidate); } } }); return result.keySet(); }
Example 7
Source File: TypeServiceImpl.java From ic with MIT License | 5 votes |
private Type mergeWithBaseType(Type type) { List<String> newRequired = Lists.newArrayList(); newRequired.addAll(baseType.getRequired()); newRequired.addAll(type.getRequired()); type.setRequired(newRequired.stream().distinct().collect(Collectors.toList())); type.setAdditionalProperties(type.getAdditionalProperties() == null ? baseType.getAdditionalProperties() : type.getAdditionalProperties()); Map<String, Object> newProperties = Maps.newLinkedHashMap(baseType.getProperties()); newProperties.putAll(type.getProperties()); type.setProperties(newProperties); return type; }
Example 8
Source File: AbstractSoftwareProcessSshDriver.java From brooklyn-server with Apache License 2.0 | 5 votes |
/** * Input stream will be closed automatically. * <p> * If using {@link SshjTool} usage, consider using {@link KnownSizeInputStream} to avoid having * to write out stream once to find its size! * * @see #copyResource(Map, String, String) for parameter descriptions. */ @Override @SuppressWarnings({ "rawtypes", "unchecked" }) public int copyResource(Map<Object,Object> sshFlags, InputStream source, String target, boolean createParentDir) { Map flags = Maps.newLinkedHashMap(); if (!sshFlags.containsKey(IGNORE_ENTITY_SSH_FLAGS)) { flags.putAll(getSshFlags()); } flags.putAll(sshFlags); String destination = Os.isAbsolutish(target) ? target : Os.mergePathsUnix(getRunDir(), target); if (createParentDir) { // don't use File.separator because it's remote machine's format, rather than local machine's int lastSlashIndex = destination.lastIndexOf("/"); String parent = (lastSlashIndex > 0) ? destination.substring(0, lastSlashIndex) : null; if (parent != null) { getMachine().execCommands("createParentDir", ImmutableList.of("mkdir -p "+parent)); } } // TODO SshMachineLocation.copyTo currently doesn't log warn on non-zero or set blocking details // (because delegated to by installTo, for multiple calls). So do it here for now. int result; String prevBlockingDetails = Tasks.setBlockingDetails("copying resource to server at "+destination); try { result = getMachine().copyTo(flags, source, destination); } finally { Tasks.setBlockingDetails(prevBlockingDetails); } if (result == 0) { log.debug("copying stream complete; {} on {}", new Object[] { destination, getMachine() }); } else { log.warn("copying stream failed; {} on {}: {}", new Object[] { destination, getMachine(), result }); } return result; }
Example 9
Source File: SerializableByteBufferMap.java From iceberg with Apache License 2.0 | 5 votes |
Object readResolve() throws ObjectStreamException { Map<Integer, ByteBuffer> map = Maps.newLinkedHashMap(); for (int i = 0; i < keys.length; i += 1) { map.put(keys[i], ByteBuffer.wrap(values[i])); } return SerializableByteBufferMap.wrap(map); }
Example 10
Source File: AdManagerJaxWsHeaderHandler.java From googleads-java-lib with Apache License 2.0 | 5 votes |
/** * Creates a map with data from the user's service session which is needed to set Ad Manager SOAP * headers. * * @param adManagerSession the user's session object * @return a map of HTTP header names to values */ private Map<String, Object> readHeaderElements(AdManagerSession adManagerSession) { // The order here must match the order of the SoapRequestHeader elements in the WSDL. Map<String, Object> mapToFill = Maps.newLinkedHashMap(); mapToFill.put("networkCode", adManagerSession.getNetworkCode()); mapToFill.put( "applicationName", userAgentCombiner.getUserAgent(adManagerSession.getApplicationName())); return mapToFill; }
Example 11
Source File: CppLangPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public Map<String, Class<?>> getBinaryTools() { Map<String, Class<?>> tools = Maps.newLinkedHashMap(); tools.put("cppCompiler", DefaultPreprocessingTool.class); return tools; }
Example 12
Source File: PdaUtil.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public <S, P> Nfa<S> filterUnambiguousPaths(Pda<S, P> pda) { Map<S, List<S>> followers = Maps.newLinkedHashMap(); Map<S, Integer> distanceMap = nfaUtil.distanceToFinalStateMap(pda); filterUnambiguousPaths(pda, pda.getStart(), distanceMap, followers); return new NfaUtil.NFAImpl<S>(pda.getStart(), pda.getStop(), followers); }
Example 13
Source File: FindExportableNodes.java From astor with GNU General Public License v2.0 | 4 votes |
public FindExportableNodes(AbstractCompiler compiler) { this.compiler = compiler; this.exports = Maps.newLinkedHashMap(); }
Example 14
Source File: Constraints.java From ldp4j with Apache License 2.0 | 4 votes |
private Shape() { this.constraints=Maps.newLinkedHashMap(); }
Example 15
Source File: Backend.java From quantumdb with Apache License 2.0 | 4 votes |
public State load(Connection connection, Catalog catalog) throws SQLException { Changelog changelog = loadChangelog(connection); Map<String, RefId> refIds = listRefIds(connection); Table<RefId, Version, String> tableVersions = listTableVersions(connection, refIds, changelog); List<TableColumn> tableColumns = listTableColumns(connection, refIds); List<TableColumnMapping> columnMappings = listTableColumnMappings(connection, tableColumns); Multimap<RefId, TableColumn> columnsPerTable = LinkedHashMultimap.create(); tableColumns.forEach(column -> columnsPerTable.put(column.getRefId(), column)); Map<TableColumn, ColumnRef> columnCache = Maps.newLinkedHashMap(); RefLog refLog = new RefLog(); List<Version> toDo = Lists.newLinkedList(); toDo.add(changelog.getRoot()); while (!toDo.isEmpty()) { Version version = toDo.remove(0); for (Entry<RefId, String> entry : tableVersions.column(version).entrySet()) { TableRef tableRef = refLog.getTableRefs(version).stream() .filter(ref -> ref.getName().equals(entry.getValue()) && ref.getRefId().equals(entry.getKey().getRefId())) .findFirst() .orElse(null); if (tableRef != null) { tableRef.markAsPresent(version); } else { Map<TableColumn, ColumnRef> columnRefs = columnsPerTable.get(entry.getKey()).stream() .collect(Collectors.toMap(Function.identity(), column -> { List<ColumnRef> basedOn = columnMappings.stream() .filter(mapping -> mapping.getTarget().equals(column)) .map(TableColumnMapping::getSource) .map(columnCache::get) .filter(ref -> ref != null) .collect(Collectors.toList()); return new ColumnRef(column.getColumn(), basedOn); }, (l, r) -> l, LinkedHashMap::new)); columnCache.putAll(columnRefs); refLog.addTable(entry.getValue(), entry.getKey().getRefId(), version, columnRefs.values()); } } if (version.getChild() != null) { toDo.add(version.getChild()); } } addSynchronizers(connection, refLog, columnMappings); setActiveVersions(connection, changelog, refLog); return new State(catalog, refLog, changelog); }
Example 16
Source File: StringKeyMapConverterTest.java From brooklyn-server with Apache License 2.0 | 4 votes |
@Test public void testSimple() throws UnknownHostException { Map m = Maps.newLinkedHashMap(); m.put("a", "v"); assertX(m, "<map>\n <a>v</a>\n</map>"); }
Example 17
Source File: AbstractControllerImpl.java From brooklyn-library with Apache License 2.0 | 4 votes |
protected void addServerPoolMemberTrackingPolicy() { Group serverPool = getServerPool(); if (serverPool == null) { return; // no-op } if (serverPoolMemberTrackerPolicy != null) { LOG.debug("Call to addServerPoolMemberTrackingPolicy when serverPoolMemberTrackingPolicy already exists, removing and re-adding, in {}", this); removeServerPoolMemberTrackingPolicy(); } for (Policy p: policies()) { if (p instanceof ServerPoolMemberTrackerPolicy) { // TODO want a more elegant idiom for this! LOG.info(this+" picking up "+p+" as the tracker (already set, often due to rebind)"); serverPoolMemberTrackerPolicy = (ServerPoolMemberTrackerPolicy) p; return; } } AttributeSensor<?> hostAndPortSensor = getConfig(HOST_AND_PORT_SENSOR); AttributeSensor<?> hostnameSensor = getConfig(HOSTNAME_SENSOR); AttributeSensor<?> portSensor = getConfig(PORT_NUMBER_SENSOR); Set<AttributeSensor<?>> sensorsToTrack; if (hostAndPortSensor != null) { sensorsToTrack = ImmutableSet.<AttributeSensor<?>>of(hostAndPortSensor); } else { sensorsToTrack = ImmutableSet.<AttributeSensor<?>>of(hostnameSensor, portSensor); } serverPoolMemberTrackerPolicy = policies().add(PolicySpec.create(ServerPoolMemberTrackerPolicy.class) .displayName("Controller targets tracker") .configure("group", serverPool) .configure("sensorsToTrack", sensorsToTrack)); LOG.info("Added policy {} to {}", serverPoolMemberTrackerPolicy, this); synchronized (serverPoolAddresses) { // Initialize ourselves immediately with the latest set of members; don't wait for // listener notifications because then will be out-of-date for short period (causing // problems for rebind) // if invoked on start, we'll have isActive=false at this point so other policies wont' run anyway, // but synch in case invoked at other times; and note if !isActive during start means we miss some after this, // we will update again on postStart after setting isActive=true Map<Entity,String> serverPoolTargets = Maps.newLinkedHashMap(); for (Entity member : serverPool.getMembers()) { if (belongsInServerPool(member)) { if (LOG.isTraceEnabled()) LOG.trace("Done {} checkEntity {}", this, member); String address = getAddressOfEntity(member); serverPoolTargets.put(member, address); } } LOG.info("Resetting {}, server pool targets {}", new Object[] {this, serverPoolTargets}); sensors().set(SERVER_POOL_TARGETS, serverPoolTargets); } }
Example 18
Source File: IPreferenceValuesProvider.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
private IPreferenceValues empty() { return new MapBasedPreferenceValues(Maps.<String, String> newLinkedHashMap()); }
Example 19
Source File: MockOperDefineController.java From dubbo-mock with Apache License 2.0 | 4 votes |
@ResponseBody @RequestMapping(value = "/selectMockRuleResults") public String selectMockRuleResults(HttpServletRequest arg0, Boolean selectFlag) throws Exception { JSONObject object = new JSONObject(); object.put("result", "success"); String method = null; String result = null; try { Map<String, String> context = Maps.newLinkedHashMap(); String serviceId = arg0.getParameter("serviceId"); String mockTestIds = arg0.getParameter("mockTestIds"); String[] mocks = mockTestIds.split(","); Integer[] integers = new Integer[mocks.length]; for (int i = 0; i < mocks.length; i++) { integers[i] = Integer.valueOf(mocks[i]); } String mockRules = arg0.getParameter("mockRules"); mockRules = URLDecoder.decode(mockRules, Charset.defaultCharset().toString()); String[] params = mockRules.split("&"); List<String> mockKeys = Lists.newArrayList(); List<String> mockValus = Lists.newArrayList(); List<String> mockTypes = Lists.newArrayList(); for (int i = 0; i < params.length; i++) { String[] param = params[i].split("="); if (param[0].equals("mockTestKey")) { if (i > 0 && ArrayUtils.contains(intelChars, param[1])) { throw new RuntimeException("KEY命名不能包含以下关键字:" + ArrayUtils.toString(intelChars)); } mockKeys.add(param[1]); } if (param[0].equals("mockTestValue")) { mockValus.add(param[1]); } if (param[0].equals("mockTestType")) { mockTypes.add(param[1]); } } for (int i = 0; i < mockKeys.size(); i++) { context.put(mockKeys.get(i), mockValus.get(i)); } method = context.remove("methodName"); result = mockTestServiceImpl.testMockService(Integer.valueOf(serviceId), method, context, integers); } catch (Exception e) { object.put("result", "error"); result = e.getMessage(); e.printStackTrace(); } object.put("context", result); return object.toJSONString(); }
Example 20
Source File: ApiBase.java From api with Apache License 2.0 | 4 votes |
private Promise getNext(Codec head, Codec key, StorageKey.StorageFunction storageMethod) { Map<Codec, Pair<Codec, Linkage<Codec>>> result = Maps.newLinkedHashMap(); //BehaviorSubject<LinkageResult>; final Promise[] subject = {null}; IRpcModule rpc = ApiBase.this.rpcBase; IRpc.RpcInterfaceSection state = rpc.state(); IRpcFunction subscribeStorage = state.function("subscribeStorage"); return subscribeStorage.invoke( new Object[]{ new Object[]{ new Object[]{storageMethod, new Object[]{key}} } } ).then((data) -> { List<Object> objects = CodecUtils.arrayLikeToList(data); objects = CodecUtils.arrayLikeToList(objects.get(0)); Linkage<Codec> linkage = (Linkage<Codec>) objects.get(1); result.put(key, Pair.of((Codec) objects.get(0), (Linkage<Codec>) objects.get(1))); // iterate from this key to the children, constructing // entries for all those found and available if (linkage.getNext().isSome()) { return getNext(head, linkage.getNext().unwrap(), storageMethod); } List<Codec> keys = Lists.newArrayList(); List<Codec> values = Lists.newArrayList(); Codec nextKey = head; // loop through the results collected, starting at the head an re-creating // the list. Our map may have old entries, based on the linking these will // not be returned in the final result while (nextKey != null) { Pair<Codec, Linkage<Codec>> entry = result.get(nextKey); if (entry == null) { break; } Codec item = entry.getLeft(); Linkage<Codec> linka = entry.getRight(); keys.add(nextKey); values.add(item); if (linka.getNext() != null) { nextKey = (Codec) linka.getNext().unwrapOr(null); } } Linkage.LinkageResult nextResult = values.isEmpty() ? new Linkage.LinkageResult( TypesUtils.getConstructorCodec(Null.class), Lists.newArrayList(), TypesUtils.getConstructorCodec(Null.class), Lists.newArrayList()) : new Linkage.LinkageResult( TypesUtils.getConstructorCodec(keys.get(0).getClass()), Lists.newArrayList(keys), TypesUtils.getConstructorCodec(values.get(0).getClass()), Lists.newArrayList(values)); if (subject[0] != null) { subject[0].then((r) -> Promise.value(nextResult)); } else { subject[0] = Promise.value(nextResult); } return subject[0]; }); }