List of usage examples for com.google.common.collect HashBiMap create
public static <K, V> HashBiMap<K, V> create()
From source file:org.apache.usergrid.security.shiro.principals.ApplicationGuestPrincipal.java
@Override public void grant(UsergridAuthorizationInfo info, EntityManagerFactory emf, ManagementService management, TokenService tokens) {/*from w ww . j a v a 2 s. c om*/ Map<UUID, String> organizationSet = HashBiMap.create(); Map<UUID, String> applicationSet = HashBiMap.create(); OrganizationInfo organization = null; ApplicationInfo application = null; role(info, Realm.ROLE_APPLICATION_USER); UUID applicationId = getApplicationId(); EntityManager em = emf.getEntityManager(applicationId); try { String appName = (String) em.getProperty(em.getApplicationRef(), "name"); applicationSet.put(applicationId, appName); application = new ApplicationInfo(applicationId, appName); } catch (Exception e) { } grant(info, getPermissionFromPath(applicationId, "access")); try { Set<String> permissions = em.getRolePermissions("guest"); grant(info, applicationId, permissions); } catch (Exception e) { logger.error("Unable to get user default role permissions", e); } info.setOrganization(organization); info.addOrganizationSet(organizationSet); info.setApplication(application); info.addApplicationSet(applicationSet); }
From source file:org.ftc.opmodes.NetworkAnalyzer.java
@Override public void init() { wifiChannelMap = HashBiMap.create(); wifiChannelMap.put(2412, "2.4G Ch01"); wifiChannelMap.put(2417, "2.4G Ch02"); wifiChannelMap.put(2422, "2.4G Ch03"); wifiChannelMap.put(2427, "2.4G Ch04"); wifiChannelMap.put(2432, "2.4G Ch05"); wifiChannelMap.put(2437, "2.4G Ch06"); wifiChannelMap.put(2442, "2.4G Ch07"); wifiChannelMap.put(2447, "2.4G Ch08"); wifiChannelMap.put(2452, "2.4G Ch09"); wifiChannelMap.put(2457, "2.4G Ch10"); wifiChannelMap.put(2462, "2.4G Ch11"); wifiChannelMap.put(2467, "2.4G Ch12"); wifiChannelMap.put(2472, "2.4G Ch13"); wifiChannelMap.put(2484, "2.4G Ch14"); wifi = (WifiManager) hardwareMap.appContext.getSystemService(Context.WIFI_SERVICE); hardwareMap.appContext.registerReceiver(new BroadcastReceiver() { @Override/*from ww w. j a va 2s. c om*/ public void onReceive(Context context, Intent intent) { LinkedList<ScanResult> results = new LinkedList<>(wifi.getScanResults()); scanResults(results); } }, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)); wifi.startScan(); try { String absolutePath = hardwareMap.appContext.getFilesDir().getAbsolutePath() + "/"; RunShellCommand cmd = new RunShellCommand(); String output; if ((output = cmd.run( String.format("cp /data/misc/wifi/p2p_supplicant.conf %sp2p_supplicant.conf \n", absolutePath))) .length() > 0) { RobotLog.e("Cannot copy p2p file" + output); operChannel = output; } String fileData = Files.toString(new File(absolutePath + "p2p_supplicant.conf"), Charset.defaultCharset()); String[] datas = fileData.split("/n"); for (String data : datas) { if (data.contains("p2p_oper_channel")) { operChannel = data.substring(data.indexOf("=")); } } } catch (IOException ex) { if (operChannel.equals("")) { operChannel = ex.getMessage(); } } }
From source file:com.kylinolap.storage.StorageContext.java
public StorageContext() { this.threshold = DEFAULT_THRESHOLD; this.limit = DEFAULT_THRESHOLD; this.totalScanCount = 0; this.cuboids = new HashSet<Cuboid>(); this.aliasMap = HashBiMap.create(); this.hasSort = false; this.sortOrders = new ArrayList<OrderEnum>(); this.sortMeasures = new ArrayList<MeasureDesc>(); this.exactAggregation = false; this.avoidAggregation = false; this.mandatoryColumns = new HashSet<TblColRef>(); this.enableLimit = false; this.acceptPartialResult = false; this.partialResultReturned = false; }
From source file:org.apache.qpid.disttest.controller.ParticipatingClients.java
private BiMap<String, String> mapConfiguredToRegisteredClientNames(List<String> configuredClientNamesForTest, ClientRegistry clientRegistry) { BiMap<String, String> configuredToRegisteredNameMap = HashBiMap.create(); TreeSet<String> registeredClients = new TreeSet<String>(clientRegistry.getClients()); for (String configuredClientName : configuredClientNamesForTest) { String allocatedClientName = registeredClients.pollFirst(); if (allocatedClientName == null) { throw new IllegalArgumentException("Too few clients in registry " + clientRegistry + " configured clients " + configuredClientNamesForTest); }//from ww w. ja va2s .com configuredToRegisteredNameMap.put(configuredClientName, allocatedClientName); } return configuredToRegisteredNameMap; }
From source file:org.jetbrains.k2js.translate.declaration.ClassDeclarationTranslator.java
public ClassDeclarationTranslator(@NotNull List<ClassDescriptor> descriptors, @NotNull TranslationContext context) { super(context); this.descriptors = descriptors; this.localToGlobalClassName = HashBiMap.create(); this.dummyFunction = new JsFunction(context.jsScope()); }
From source file:edu.cuny.qc.speech.AuToBI.classifier.LibLinearClassifier.java
public LibLinearClassifier(SolverType solver, boolean class_weighting) { Linear.setDebugOutput(null);/*from w w w .j a v a2 s . c om*/ this.solver = solver; this.C = 1.0; this.eps = 0.01; this.class_weighting = class_weighting; this.norm_map = new HashMap<String, Aggregation>(); this.feature_map = HashBiMap.create(); }
From source file:uk.ac.ebi.mdk.tool.domain.TransportReactionUtil.java
public static <T> BiMap<CompartmentalisedParticipant<T, ?, Compartment>, CompartmentalisedParticipant<T, ?, Compartment>> getMappings( Reaction<? extends CompartmentalisedParticipant<T, ?, Compartment>> transportReaction, Comparator<T> comparator) { BiMap<CompartmentalisedParticipant<T, ?, Compartment>, CompartmentalisedParticipant<T, ?, Compartment>> mappings = HashBiMap .create();//ww w. j a v a 2 s . co m for (CompartmentalisedParticipant<T, ?, Compartment> p1 : transportReaction.getReactants()) { for (CompartmentalisedParticipant<T, ?, Compartment> p2 : transportReaction.getProducts()) { if (comparator.compare(p1.getMolecule(), p2.getMolecule()) == 0) { mappings.put(p1, p2); } } } return mappings; }
From source file:edu.usf.cutr.gtfsrtvalidator.validation.rules.CrossFeedDescriptorValidator.java
@Override public List<ErrorListHelperModel> validate(long currentTimeMillis, GtfsDaoImpl gtfsData, GtfsMetadata gtfsMetadata, GtfsRealtime.FeedMessage feedMessage, GtfsRealtime.FeedMessage previousFeedMessage) { List<OccurrenceModel> w003List = new ArrayList<>(); List<OccurrenceModel> e047List = new ArrayList<>(); // key is trip_id from TripUpdates feed, value is vehicle.id BiMap<String, String> tripUpdates = HashBiMap.create(); // A set of trips (key = trip_id) that don't have any vehicle.ids Set<String> tripsWithoutVehicles = new HashSet<>(); int tripUpdateCount = 0; // key is vehicle_id from VehiclePositions feed, value is trip_id BiMap<String, String> vehiclePositions = HashBiMap.create(); // A set of vehicles (key = vehicle.id) that don't have any trip_ids Set<String> vehiclesWithoutTrips = new HashSet<>(); int vehiclePositionCount = 0; // Build the maps for (GtfsRealtime.FeedEntity entity : feedMessage.getEntityList()) { if (entity.hasTripUpdate() && hasTripId(entity.getTripUpdate())) { tripUpdateCount++;/* ww w . jav a 2 s . c o m*/ String tripId = entity.getTripUpdate().getTrip().getTripId(); String vehicleId = ""; if (entity.getTripUpdate().hasVehicle() && entity.getTripUpdate().getVehicle().hasId()) { vehicleId = entity.getTripUpdate().getVehicle().getId(); } if (StringUtil.isEmpty(vehicleId)) { // Trip does not have a vehicle.id - add it to the set (it can't exist in HashBiMap) tripsWithoutVehicles.add(tripId); } else { // Trip has a vehicle.id - add it to the HashBiMap try { tripUpdates.put(tripId, vehicleId); } catch (IllegalArgumentException e) { // TODO - We should log this as error under new rule - see https://github.com/CUTR-at-USF/gtfs-realtime-validator/issues/33 _log.error("Error adding trip_id " + tripId + " -> vehicle_id " + vehicleId + " to TripUpdates HashBiMap. TripUpdate exists twice in feed, or more than one TripUpdate is assigned to the same vehicle. " + e); } } } if (entity.hasVehicle() && hasVehicleId(entity.getVehicle())) { vehiclePositionCount++; String vehicleId = entity.getVehicle().getVehicle().getId(); String tripId = ""; if (entity.getVehicle().hasTrip() && entity.getVehicle().getTrip().hasTripId()) { tripId = entity.getVehicle().getTrip().getTripId(); } if (StringUtil.isEmpty(tripId)) { // Vehicle does not have a trip_id - add it to the set (it can't exist in HashBiMap) vehiclesWithoutTrips.add(vehicleId); } else { // Vehicle has a trip_id - add it to the HashBiMap try { vehiclePositions.put(vehicleId, tripId); } catch (IllegalArgumentException e) { // TODO - We should log this as error under new rule - see https://github.com/CUTR-at-USF/gtfs-realtime-validator/issues/38 _log.error("Error adding vehicle.id " + vehicleId + " -> trip_id " + tripId + " to VehiclePositions HashBiMap. Vehicle exists twice in feed, or more than one vehicle is assigned to same trip. " + e); } } } } List<ErrorListHelperModel> errors = new ArrayList<>(); if (tripUpdateCount == 0 || vehiclePositionCount == 0) { // We are missing a VehiclePositions or TripUpdates feed, so we can't compare across feeds - return empty list; return errors; } /** * Create inverse maps, so we can efficiently check if a trip_id in TripUpdates is in VehiclePositions, and if * vehicle_id in VehiclePositions is in TripUpdates. * * tripUpdatesInverse - A map of vehicle_ids to trip_ids, from the TripUpdates feed * vehiclePositionsInverse - A map of trip_ids to vehicle_ids, from the VehiclePositions feed * * Note that we still need to check vehiclesWithoutTrips and tripsWithoutVehicles, as these trips/vehicles can't exist in HashBiMaps. * See https://github.com/CUTR-at-USF/gtfs-realtime-validator/issues/241#issuecomment-313194304. */ BiMap<String, String> tripUpdatesInverse = tripUpdates.inverse(); BiMap<String, String> vehiclePositionsInverse = vehiclePositions.inverse(); // Check all trips that contained a vehicle for (Map.Entry<String, String> trip : tripUpdates.entrySet()) { if (!vehiclePositionsInverse.containsKey(trip.getKey())) { // W003 - TripUpdates feed has a trip_id that's not in VehiclePositions feed RuleUtils.addOccurrence(W003, "trip_id " + trip.getKey() + " is in TripUpdates but not in VehiclePositions feed", w003List, _log); } if (!vehiclePositions.containsKey(trip.getValue()) && !vehiclesWithoutTrips.contains(trip.getValue())) { // W003 - TripUpdates feed has a vehicle_id that's not in VehiclePositions feed RuleUtils.addOccurrence(W003, "vehicle_id " + trip.getValue() + " is in TripUpdates but not in VehiclePositions feed", w003List, _log); } checkE047TripUpdates(trip, vehiclePositionsInverse, e047List); } // Check all vehicles that contained a trip for (Map.Entry<String, String> vehiclePosition : vehiclePositions.entrySet()) { if (!tripUpdatesInverse.containsKey(vehiclePosition.getKey())) { // W003 - VehiclePositions has a vehicle_id that's not in TripUpdates feed RuleUtils.addOccurrence(W003, "vehicle_id " + vehiclePosition.getKey() + " is in VehiclePositions but not in TripUpdates feed", w003List, _log); } if (!tripUpdates.containsKey(vehiclePosition.getValue()) && !tripsWithoutVehicles.contains(vehiclePosition.getValue())) { // W003 - VehiclePositions has a trip_id that's not in the TripUpdates feed RuleUtils.addOccurrence(W003, "trip_id " + vehiclePosition.getValue() + " is in VehiclePositions but not in TripUpdates feed", w003List, _log); } checkE047VehiclePositions(vehiclePosition, tripUpdatesInverse, e047List); } // Check all trips that did NOT contain a vehicle for (String trip_id : tripsWithoutVehicles) { if (!vehiclePositionsInverse.containsKey(trip_id)) { // W003 - TripUpdates feed has a trip_id that's not in VehiclePositions feed RuleUtils.addOccurrence(W003, "trip_id " + trip_id + " is in TripUpdates but not in VehiclePositions feed", w003List, _log); } } // Check all vehicles that did NOT contain a trip for (String vehicle_id : vehiclesWithoutTrips) { if (!tripUpdatesInverse.containsKey(vehicle_id)) { // W003 - VehiclePositions has a vehicle_id that's not in TripUpdates feed RuleUtils.addOccurrence(W003, "vehicle_id " + vehicle_id + " is in VehiclePositions but not in TripUpdates feed", w003List, _log); } } if (!w003List.isEmpty()) { errors.add(new ErrorListHelperModel(new MessageLogModel(W003), w003List)); } if (!e047List.isEmpty()) { errors.add(new ErrorListHelperModel(new MessageLogModel(E047), e047List)); } return errors; }
From source file:eu.esdihumboldt.hale.io.csv.ui.ReadConfigurationPage.java
/** * default constructor//from w ww . j av a 2 s . com */ public ReadConfigurationPage() { super("CSVRead"); setTitle("Reader Settings"); setDescription("Set the Separating character, Quote character and Escape character"); bmap = HashBiMap.create(); bmap.put("TAB", "\t"); }
From source file:org.grouplens.lenskit.eval.traintest.JobStatusWriter.java
/** * Create a new job status writer./* w w w . j a v a 2 s . c o m*/ * @param file The output file. */ public JobStatusWriter(TrainTestEvalTask task, Set<TrainTestJob> jobs, File file) { this.task = task; outputFile = file; finishedJobs = Sets.newHashSet(); activeJobs = Sets.newHashSet(); allJobs = ImmutableSet.copyOf(jobs); threads = HashBiMap.create(); startTime = Maps.newHashMap(); }