List of usage examples for com.google.common.collect HashBiMap create
public static <K, V> HashBiMap<K, V> create()
From source file:com.voxelplugineering.voxelsniper.shape.ComplexMaterialShape.java
/** * Creates a new {@link MaterialShape}.// ww w . j ava 2 s . c o m * * @param shape the shape * @param defaultMaterial the default material for the shape */ public ComplexMaterialShape(Shape shape, Material defaultMaterial) { checkNotNull(shape); checkNotNull(defaultMaterial, "Default material cannot be null!"); if (shape instanceof ComplexShape) { this.shape = shape; } else { this.shape = new ComplexShape(shape); } this.materialDictionary = HashBiMap.create(); this.inverseDictionary = this.materialDictionary.inverse(); this.materialsA = new byte[shape.getWidth() * shape.getLength() * shape.getHeight()]; this.materialDictionary.put((short) 0, defaultMaterial); this.flood(defaultMaterial); this.defaultMaterial = defaultMaterial; }
From source file:eu.itesla_project.cim1.converter.CIM1PsseNamingStrategy.java
private BiMap<String, String> getIdMapping() { if (idMapping == null) { idMapping = HashBiMap.create(); // check names are uniques Set<String> names = new HashSet<>(); for (cim1.model.SubGeographicalRegion r : model.getId_SubGeographicalRegion().values()) { addName(idMapping, names, r); }//from ww w . ja v a 2 s . c o m for (cim1.model.Substation s : model.getId_Substation().values()) { addName(idMapping, names, s); } for (cim1.model.VoltageLevel vl : model.getId_VoltageLevel().values()) { addName(idMapping, names, vl); } for (cim1.model.ACLineSegment l : model.getId_ACLineSegment().values()) { addName(idMapping, names, l); } for (cim1.model.PowerTransformer twt : model.getId_PowerTransformer().values()) { addName(idMapping, names, twt); } for (cim1.model.Switch s : model.getId_Switch().values()) { addName(idMapping, names, s); } for (cim1.model.SynchronousMachine sm : model.getId_SynchronousMachine().values()) { addName(idMapping, names, sm); } for (cim1.model.EnergyConsumer ec : model.getId_EnergyConsumer().values()) { addName(idMapping, names, ec); } for (cim1.model.ShuntCompensator sc : model.getId_ShuntCompensator().values()) { addName(idMapping, names, sc); } for (cim1.model.TopologicalNode tn : model.getId_TopologicalNode().values()) { addName(idMapping, names, tn); } } return idMapping; }
From source file:com.bigdata.dastor.client.RingCache.java
public void refreshEndPointMap() { for (String seed : seeds_) { try {// w ww .j a v a2 s . com TSocket socket = new TSocket(seed, port_); TBinaryProtocol binaryProtocol = new TBinaryProtocol(socket, false, false); Dastor.Client client = new Dastor.Client(binaryProtocol); socket.open(); Map<String, String> tokenToHostMap = (Map<String, String>) JSONValue .parse(client.get_string_property(DastorThriftServer.TOKEN_MAP)); BiMap<Token, InetAddress> tokenEndpointMap = HashBiMap.create(); for (Map.Entry<String, String> entry : tokenToHostMap.entrySet()) { Token token = StorageService.getPartitioner().getTokenFactory().fromString(entry.getKey()); String host = entry.getValue(); try { tokenEndpointMap.put(token, InetAddress.getByName(host)); } catch (UnknownHostException e) { throw new AssertionError(e); // host strings are IPs } } tokenMetadata = new TokenMetadata(tokenEndpointMap); break; } catch (TException e) { /* let the Exception go and try another seed. log this though */ logger_.debug("Error contacting seed " + seed + " " + e.getMessage()); } } }
From source file:com.torodb.torod.db.postgresql.meta.CollectionSchema.java
private CollectionSchema(String schemaName, Iterable<? extends Table> tables, DSLContext dsl, DatabaseMetaData jdbcMeta) { super(schemaName); this.collection = schemaNameToCollection(schemaName); this.typesById = HashBiMap.create(); this.tables = Maps.newHashMap(); this.structureConverter = new StructureConverter(this); this.structuresCache = new StructuresCache(schemaName, structureConverter); int maxTypeId = MIN_VALUE_TABLE_ID; for (Table<?> table : tables) { if (SubDocTable.isSubDocTable(table.getName())) { SubDocTable subDocTable = new SubDocTable(table.getName(), this, jdbcMeta); int subDocId = subDocTable.getTypeId(); SubDocType type = subDocTable.getSubDocType(); this.tables.put(type, subDocTable); this.typesById.put(subDocId, type); if (maxTypeId < subDocId) { maxTypeId = subDocId;/*from w w w.j a v a 2s. c o m*/ } } } this.typeIdProvider = new AtomicInteger(maxTypeId); this.structureConverter.initialize(); this.structuresCache.initialize(dsl, tables); }
From source file:edu.rit.flick.genetics.ByteConverterBiMapFactory.java
/** * @param segmentLength/*from ww w .java 2 s. c o m*/ * @return */ public BiMap<String, Byte> getByteConverter(final int segmentLength) { final BiMap<String, Byte> byteConverter = HashBiMap.create(); final AtomicInteger permutationId = new AtomicInteger(Byte.MIN_VALUE); fillConverterMapFullSize("", permutationId, segmentLength, byteConverter); return byteConverter; }
From source file:org.gw2InfoViewer.services.json.JsonConversionService.java
public static MapNames parseMapNames(String json) { BiMap<Integer, String> nameHashBiMap; JsonArray jsonArray;/* ww w . j a v a2 s . c om*/ nameHashBiMap = HashBiMap.create(); jsonArray = new JsonParser().parse(json).getAsJsonArray(); for (int i = 0; i < jsonArray.size(); i++) { IdNamePair namePair; namePair = gsonBuilder.create().fromJson(jsonArray.get(i), IdNamePair.class); nameHashBiMap.put(Integer.parseInt(namePair.getId()), namePair.getName()); } return new MapNames(nameHashBiMap); }
From source file:de.uni_potsdam.hpi.asg.delaymatch.model.DelayMatchModule.java
public DelayMatchModule(VerilogModule module, ProfileComponent profilecomp) { this.module = module; this.profilecomp = profilecomp; this.instances = new ArrayList<>(); this.measureRecords = HashBiMap.create(); this.requesters = new HashMap<>(); this.targetValue = HashBasedTable.create(); this.minValueFactor = HashBasedTable.create(); this.maxValueFactor = HashBasedTable.create(); this.pathMinValueFactor = new HashMap<>(); this.pathMaxValueFactor = new HashMap<>(); }
From source file:com.davidbracewell.conversion.impl.MapConverter.java
public MapConverter(Function<Object, K> keyConverter, Function<Object, V> valueConverter, final Class<?> mapClass) { Preconditions.checkNotNull(mapClass); Preconditions.checkNotNull(keyConverter); Preconditions.checkNotNull(valueConverter); Preconditions.checkArgument(Map.class.isAssignableFrom(mapClass), "Must specify a class that implements Map."); this.keyConverter = keyConverter; this.valueConverter = valueConverter; this.mapSupplier = new Supplier<T>() { @Override//w w w.j a v a2s . c o m public T get() { if (BiMap.class.equals(mapClass)) { return Cast.as(HashBiMap.create()); } else if (Map.class.equals(mapClass)) { return Cast.as(new HashMap()); } try { return Reflect.onClass(mapClass).create().get(); } catch (ReflectionException e) { throw Throwables.propagate(e); } } }; }
From source file:annis.gui.widgets.gwt.client.ui.VAnnotationGrid.java
/** * The constructor should first call super() to initialize the component and * then handle any initialization relevant to Vaadin. *//* w w w .j a va2 s . com*/ public VAnnotationGrid() { super(); table = new AnnotationGridTable(); formatter = table.getFlexCellFormatter(); // we are wrapping the table element initWidget(table); // This method call of the Paintable interface sets the component // style name in DOM tree setStyleName(CLASSNAME); highlighted = new HashMap<String, String[]>(); position2id = HashBiMap.create(); startTimes = new HashMap<Position, Double>(); endTimes = new HashMap<Position, Double>(); pdfPageNumbers = new HashMap<Position, String>(); }
From source file:seeit3d.base.model.PolyCylinder.java
public PolyCylinder(String name, Map<MetricCalculator, String> metricsValues, IEclipseResourceRepresentation representation) { this.name = name; this.metricsValues = metricsValues; this.representation = representation; visualPropertyValues = new ArrayList<VisualPropertyValue>(); identifier = Utils.generatePolyCylinderIdentifier(); propertiesMap = HashBiMap.create(); SeeIT3D.injector().injectMembers(this); }