类com.google.common.collect.BiMap源码实例Demo

下面列出了怎么用com.google.common.collect.BiMap的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: usergrid   文件: ManagementServiceImpl.java
@Override
public Map<String, Object> getOrganizationData( OrganizationInfo organization ) throws Exception {

    Map<String, Object> jsonOrganization = new HashMap<>();
    jsonOrganization.putAll( JsonUtils.toJsonMap( organization ) );

    BiMap<UUID, String> applications = getApplicationsForOrganization( organization.getUuid() );
    jsonOrganization.put( "applications", applications.inverse() );

    List<UserInfo> users = getAdminUsersForOrganization( organization.getUuid() );
    Map<String, Object> jsonUsers = new HashMap<>();
    for ( UserInfo u : users ) {
        jsonUsers.put( u.getUsername(), u );
    }
    jsonOrganization.put( "users", jsonUsers );

    return jsonOrganization;
}
 
源代码2 项目: Gadomancy   文件: ModSubstitutions.java
public static void preInit() {
        if(ModConfig.enableAdditionalNodeTypes) {
            try {
                ItemBlock item = (ItemBlock) Item.getItemFromBlock(ConfigBlocks.blockAiry);

                item.field_150939_a = RegisteredBlocks.blockNode;

                //Hacky way
                FMLControlledNamespacedRegistry<Block> registry = GameData.getBlockRegistry();
                registry.underlyingIntegerMap.field_148749_a.put(RegisteredBlocks.blockNode, Block.getIdFromBlock(ConfigBlocks.blockAiry));
                registry.underlyingIntegerMap.field_148748_b.set(Block.getIdFromBlock(ConfigBlocks.blockAiry), RegisteredBlocks.blockNode);
                ((BiMap)registry.field_148758_b).forcePut(RegisteredBlocks.blockNode, registry.field_148758_b.get(ConfigBlocks.blockAiry));

                registry.underlyingIntegerMap.field_148749_a.remove(ConfigBlocks.blockAiry);

                ConfigBlocks.blockAiry = RegisteredBlocks.blockNode;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
}
 
源代码3 项目: Bats   文件: AbstractMaterializedViewRule.java
/**
 * It swaps the table references and then the column references of the input
 * expressions using the table mapping and the equivalence classes.
 */
private static NodeLineage generateSwapTableColumnReferencesLineage(RexBuilder rexBuilder, RelMetadataQuery mq,
        RelNode node, BiMap<RelTableRef, RelTableRef> tableMapping, EquivalenceClasses ec,
        List<RexNode> nodeExprs) {
    final Map<RexNode, Integer> exprsLineage = new HashMap<>();
    final Map<RexNode, Integer> exprsLineageLosslessCasts = new HashMap<>();
    for (int i = 0; i < nodeExprs.size(); i++) {
        final Set<RexNode> s = mq.getExpressionLineage(node, nodeExprs.get(i));
        if (s == null) {
            // Next expression
            continue;
        }
        // We only support project - filter - join, thus it should map to
        // a single expression
        assert s.size() == 1;
        // Rewrite expr. First we swap the table references following the table
        // mapping, then we take first element from the corresponding equivalence class
        final RexNode e = RexUtil.swapTableColumnReferences(rexBuilder, s.iterator().next(), tableMapping,
                ec.getEquivalenceClassesMap());
        exprsLineage.put(e, i);
        if (RexUtil.isLosslessCast(e)) {
            exprsLineageLosslessCasts.put(((RexCall) e).getOperands().get(0), i);
        }
    }
    return new NodeLineage(exprsLineage, exprsLineageLosslessCasts);
}
 
/**
 * For every TouchDelegate with a rectangular hit region, record the region on the delegatee's
 * ViewHierarchyElement using {@link ViewHierarchyElement#addTouchDelegateBounds(Rect)}
 */
@RequiresApi(Build.VERSION_CODES.Q)
private void resolveTouchDelegateRelationshipsAmongInfos(
    BiMap<Long, AccessibilityNodeInfo> originMap) {
  for (Map.Entry<Long, AccessibilityNodeInfo> entry : originMap.entrySet()) {
    TouchDelegateInfo delegateInfo = entry.getValue().getTouchDelegateInfo();
    if (delegateInfo != null) {
      for (int i = 0; i < delegateInfo.getRegionCount(); ++i) {
        Region hitRegion = delegateInfo.getRegionAt(i);
        if ((hitRegion != null) && hitRegion.isRect()) {
          AccessibilityNodeInfo delegateeNode = delegateInfo.getTargetForRegion(hitRegion);
          ViewHierarchyElement delegatee =
              (delegateeNode != null) ? findElementByNodeInfo(delegateeNode, originMap) : null;
          if (delegatee != null) {
            android.graphics.Rect hitRect = hitRegion.getBounds();
            delegatee.addTouchDelegateBounds(
                new Rect(hitRect.left, hitRect.top, hitRect.right, hitRect.bottom));
          }
        }
      }
    }
  }
}
 
源代码5 项目: calcite   文件: MaterializedViewRule.java
/**
 * First, the method takes the node expressions {@code nodeExprs} and swaps the table
 * and column references using the table mapping and the equivalence classes.
 * If {@code swapTableColumn} is true, it swaps the table reference and then the column reference,
 * otherwise it swaps the column reference and then the table reference.
 *
 * <p>Then, the method will rewrite the input expression {@code exprToRewrite}, replacing the
 * {@link RexTableInputRef} by references to the positions in {@code nodeExprs}.
 *
 * <p>The method will return the rewritten expression. If any of the expressions in the input
 * expression cannot be mapped, it will return null.
 */
protected RexNode rewriteExpression(
    RexBuilder rexBuilder,
    RelMetadataQuery mq,
    RelNode targetNode,
    RelNode node,
    List<RexNode> nodeExprs,
    BiMap<RelTableRef, RelTableRef> tableMapping,
    EquivalenceClasses ec,
    boolean swapTableColumn,
    RexNode exprToRewrite) {
  List<RexNode> rewrittenExprs = rewriteExpressions(rexBuilder, mq, targetNode, node, nodeExprs,
      tableMapping, ec, swapTableColumn, ImmutableList.of(exprToRewrite));
  if (rewrittenExprs == null) {
    return null;
  }
  assert rewrittenExprs.size() == 1;
  return rewrittenExprs.get(0);
}
 
源代码6 项目: levelup-java-examples   文件: ReverseMapLookup.java
@Test
public void flip_map_entries_with_guava() {

	BiMap<String, String> stateCodeToDescription = HashBiMap.create();

	stateCodeToDescription.put("WI", "Wisconsin");
	stateCodeToDescription.put("MN", "Minnesota");
	stateCodeToDescription.put("FL", "Florida");
	stateCodeToDescription.put("IA", "Iowa");
	stateCodeToDescription.put("OH", "Ohio");

	BiMap<String, String> descriptionToStateCode = stateCodeToDescription
			.inverse();

	logger.info(descriptionToStateCode);

	assertEquals("WI", descriptionToStateCode.get("Wisconsin"));
}
 
源代码7 项目: securify   文件: AbstractDecompiler.java
protected static BiMap<Integer, String> findTags(final PrintStream log, List<Integer> jumpDestinations) {
	// print tags (jumpdests)
	log.println();
	log.println("Tags:");
	/* Map bytecode offsets to tags/labels and vice versa. */
	BiMap<Integer, String> tags = HashBiMap.create();
	{
		for (int i = 0; i < jumpDestinations.size(); i++) {
			Integer bytecodeOffset = jumpDestinations.get(i);
			String tagLabel = "tag_" + (i + 1);
			tags.put(bytecodeOffset, tagLabel);
			log.println(tagLabel + " @" + HexPrinter.toHex(bytecodeOffset));
		}
		// add virtual tags (error and exit)
		tags.put(ControlFlowDetector.DEST_ERROR, "ERROR");
		tags.put(ControlFlowDetector.DEST_EXIT, "EXIT");
	}
	return tags;
}
 
/**
 * For every View in {@code originMap} that has a labelFor value, set labeledBy on the
 * ViewHierarchyElementAndroid that represents the View with the referenced View ID.
 */
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void resolveLabelForRelationshipsAmongViews(
    Context context, BiMap<Long, View> originMap) {
  for (Map.Entry<Long, View> entry : originMap.entrySet()) {
    int labeledViewId = entry.getValue().getLabelFor();
    if (labeledViewId != View.NO_ID) {
      ViewHierarchyElementAndroid labelElement = getViewById(entry.getKey());
      ViewHierarchyElementAndroid labeledElement = findElementByViewId(labeledViewId, originMap);
      if (labeledElement == null) {
        LogUtils.w(
            TAG, "View not found for labelFor = %1$s", resourceName(context, labeledViewId));
      } else {
        labeledElement.setLabeledBy(labelElement);
      }
    }
  }
}
 
源代码9 项目: api-mining   文件: PAM.java
/**
 * Mine API call sequences using PAM
 *
 * @param arffFile
 *            API calls in ARF Format. Attributes are fqCaller and fqCalls
 *            as space separated string of API calls.
 */
public static void mineAPICallSequences(final String arffFile, final String outFile,
		final InferenceAlgorithm inferenceAlgorithm, final int maxStructureSteps, final int maxEMIterations,
		final File logFile) throws Exception {

	final File fout = new File(outFile);
	if (fout.getParentFile() != null)
		fout.getParentFile().mkdirs();

	System.out.print("  Creating temporary transaction DB... ");
	final File transactionDB = File.createTempFile("APICallDB", ".txt");
	final BiMap<String, Integer> dictionary = HashBiMap.create();
	generateTransactionDatabase(arffFile, dictionary, transactionDB);
	System.out.println("done.");

	System.out.print("  Mining interesting sequences... ");
	final Map<Sequence, Double> sequences = PAMCore.mineInterestingSequences(transactionDB, inferenceAlgorithm,
			maxStructureSteps, maxEMIterations, logFile);
	transactionDB.delete();
	System.out.println("done.");

	decodeInterestingSequences(sequences, dictionary, outFile);
}
 
源代码10 项目: nuls-v2   文件: ObjectRef.java
public String getEncoded(BiMap<String, String> classNames) {
        StringBuilder sb = new StringBuilder();
//        Integer i = map.get(desc);
//        if (i == null) {
//            i = 0;
//        }
//        map.put(desc, i + 1);
        String s = desc;
        String s1 = classNames.inverse().get(s);
        if (s1 != null) {
            s = s1;
        }
        sb.append(ref).append(",").append(s);
        for (int dimension : dimensions) {
            sb.append(",").append(dimension);
        }
        return sb.toString();
    }
 
源代码11 项目: nuls-v2   文件: JsonUtils.java
public static String encodeArray(Object value, Class<?> elementType, BiMap<String, String> classNames) {
    String json;
    if (elementType == ObjectRef.class) {
        int length = Array.getLength(value);
        String[] array = new String[length];
        for (int i = 0; i < length; i++) {
            ObjectRef objectRef = (ObjectRef) Array.get(value, i);
            if (objectRef != null) {
                array[i] = objectRef.getEncoded(classNames);
            }
        }
        json = toJson(array);
    } else {
        json = toJson(value);
    }
    return json;
}
 
源代码12 项目: yangtools   文件: DerivedFromXPathFunctionTest.java
@Test
public void testInvalidTypeOfCorrespondingSchemaNode() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(DerivedFromXPathFunctionTest.class,
            "/yang-xpath-functions-test/derived-from-function/bar-invalid.yang");
    assertNotNull(schemaContext);

    final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
    final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(ID_C2_IDENTITY));

    final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
    converterBiMap.put("bar-prefix", BAR_MODULE);

    final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
            (JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));

    final NormalizedNodeContext normalizedNodeContext = normalizedNodeContextSupport.createContext(
            buildPathToIdrefLeafNode());

    final Function derivedFromFunction = normalizedNodeContextSupport.getFunctionContext()
            .getFunction(null, null, "derived-from");

    assertFalse(getDerivedFromResult(derivedFromFunction, normalizedNodeContext, "some-identity"));
}
 
源代码13 项目: yangtools   文件: EnumValueXPathFunctionTest.java
@Test
public void testInvalidTypeOfCorrespondingSchemaNode() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(EnumValueXPathFunctionTest.class,
            "/yang-xpath-functions-test/enum-value-function/foo-invalid.yang");
    assertNotNull(schemaContext);

    final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
    final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode("major"));

    final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
    converterBiMap.put("foo-prefix", FOO_MODULE);

    final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
            (JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));

    final NormalizedNodeContext normalizedNodeContext = normalizedNodeContextSupport.createContext(
            buildPathToSeverityLeafNode("major"));

    final Function enumValueFunction = normalizedNodeContextSupport.getFunctionContext()
            .getFunction(null, null, "enum-value");
    final Double enumValueResult = (Double) enumValueFunction.call(normalizedNodeContext, ImmutableList.of());
    assertEquals(Double.NaN, enumValueResult, 0.001);
}
 
源代码14 项目: yangtools   文件: BitIsSetXPathFunctionTest.java
@Test
public void testInvalidTypeOfCorrespondingSchemaNode() throws Exception {
    final Set<String> setOfBits = ImmutableSet.of("UP", "PROMISCUOUS");

    final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(BitIsSetXPathFunctionTest.class,
            "/yang-xpath-functions-test/bit-is-set-function/foo-invalid.yang");
    assertNotNull(schemaContext);

    final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
    final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(setOfBits));

    final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
    converterBiMap.put("foo-prefix", FOO_MODULE);

    final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
            (JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));

    final NormalizedNodeContext normalizedNodeContext = normalizedNodeContextSupport.createContext(
            buildPathToFlagsLeafNode(setOfBits));

    final Function bitIsSetFunction = normalizedNodeContextSupport.getFunctionContext()
            .getFunction(null, null, "bit-is-set");
    boolean bitIsSetResult = (boolean) bitIsSetFunction.call(normalizedNodeContext, ImmutableList.of("UP"));
    assertFalse(bitIsSetResult);
}
 
源代码15 项目: nuls   文件: ObjectRef.java
public ObjectRef(String str, BiMap<String, String> classNames) {
    String[] parts = str.split(",");
    int[] dimensions = new int[parts.length - 2];
    for (int i = 0; i < dimensions.length; i++) {
        int dimension = Integer.valueOf(parts[i + 2]);
        dimensions[i] = dimension;
    }
    this.ref = parts[0];
    String s = parts[1];
    String s1 = classNames.get(s);
    if (s1 != null) {
        s = s1;
    }
    this.desc = s;
    this.dimensions = dimensions;
    this.variableType = VariableType.valueOf(this.desc);
}
 
源代码16 项目: usergrid   文件: SubjectUtils.java
@SuppressWarnings( "unchecked" )
public static BiMap<UUID, String> getApplications() {
    Subject currentUser = getSubject();
    if ( currentUser == null ) {
        return null;
    }
    if ( !currentUser.hasRole( ROLE_APPLICATION_ADMIN ) && !currentUser.hasRole( ROLE_APPLICATION_USER ) ) {
        return null;
    }
    Session session = currentUser.getSession();

    BiMap<UUID, String> applications = HashBiMap.create();
    Map map = (Map)session.getAttribute( "applications" );
    applications.putAll(map);
    return applications;
}
 
源代码17 项目: nexus-public   文件: UpgradeManager.java
/**
 * Indexes each {@link Checkpoint} registered in the system.
 */
private BiMap<String, Checkpoint> indexCheckpoints(final List<Checkpoint> checkpoints,
                                                   final List<String> problems)
{
  Map<String, List<Checkpoint>> byName = checkpoints.stream()
      .collect(groupingBy(c -> c.getClass().isAnnotationPresent(Checkpoints.class)
          ? c.getClass().getAnnotation(Checkpoints.class).model() : null));

  if (byName.containsKey(null)) {
    byName.remove(null).stream()
        .map(c -> String.format("Checkpoint %s is not annotated with @Checkpoints", className(c)))
        .collect(toCollection(() -> problems));
  }

  byName.entrySet().stream()
      .filter(e -> e.getValue().size() > 1)
      .map(e -> String.format("Checkpoint of model: %s duplicated by classes: %s",
          e.getKey(), classNames(e.getValue())))
      .collect(toCollection(() -> problems));

  return byName.entrySet().stream()
      .collect(toImmutableBiMap(e -> e.getKey(), e -> e.getValue().get(0)));
}
 
源代码18 项目: yangtools   文件: EnumValueXPathFunctionTest.java
@Test
public void testInvalidNormalizedNodeValueType() throws Exception {
    final SchemaContext schemaContext = YangParserTestUtils.parseYangResources(EnumValueXPathFunctionTest.class,
            "/yang-xpath-functions-test/enum-value-function/foo.yang");
    assertNotNull(schemaContext);

    final XPathSchemaContext jaxenSchemaContext = SCHEMA_CONTEXT_FACTORY.createContext(schemaContext);
    final XPathDocument jaxenDocument = jaxenSchemaContext.createDocument(buildMyContainerNode(100));

    final BiMap<String, QNameModule> converterBiMap = HashBiMap.create();
    converterBiMap.put("foo-prefix", FOO_MODULE);

    final NormalizedNodeContextSupport normalizedNodeContextSupport = NormalizedNodeContextSupport.create(
            (JaxenDocument) jaxenDocument, Maps.asConverter(converterBiMap));

    final NormalizedNodeContext normalizedNodeContext = normalizedNodeContextSupport.createContext(
            buildPathToSeverityLeafNode(100));

    final Function enumValueFunction = normalizedNodeContextSupport.getFunctionContext()
            .getFunction(null, null, "enum-value");
    final Double enumValueResult = (Double) enumValueFunction.call(normalizedNodeContext, ImmutableList.of());
    assertEquals(Double.NaN, enumValueResult, 0.001);
}
 
源代码19 项目: incubator-pinot   文件: SqlQueryBuilder.java
public PreparedStatement createFindByParamsStatement(Connection connection,
    Class<? extends AbstractEntity> entityClass, Predicate predicate) throws Exception {
  String tableName =
      entityMappingHolder.tableToEntityNameMap.inverse().get(entityClass.getSimpleName());
  BiMap<String, String> entityNameToDBNameMapping =
      entityMappingHolder.columnMappingPerTable.get(tableName).inverse();
  StringBuilder sqlBuilder = new StringBuilder("SELECT * FROM " + tableName);
  StringBuilder whereClause = new StringBuilder(" WHERE ");
  List<Pair<String, Object>> parametersList = new ArrayList<>();
  generateWhereClause(entityNameToDBNameMapping, predicate, parametersList, whereClause);
  sqlBuilder.append(whereClause.toString());
  LOG.debug("createFindByParamsStatement Query: {}", sqlBuilder);
  PreparedStatement prepareStatement = connection.prepareStatement(sqlBuilder.toString());
  int parameterIndex = 1;
  LinkedHashMap<String, ColumnInfo> columnInfoMap =
      entityMappingHolder.columnInfoPerTable.get(tableName);
  for (Pair<String, Object> pair : parametersList) {
    String dbFieldName = pair.getKey();
    ColumnInfo info = columnInfoMap.get(dbFieldName);
    Preconditions.checkNotNull(info, String.format("Found field '%s' but expected %s", dbFieldName, columnInfoMap.keySet()));
    prepareStatement.setObject(parameterIndex++, pair.getValue(), info.sqlType);
    LOG.debug("Setting {} to {}", pair.getKey(), pair.getValue());
  }
  return prepareStatement;
}
 
源代码20 项目: OpenModsLib   文件: CommonRegistryCallbacks.java
public static <T, E extends IForgeRegistryEntry<E>> Integer mapObjectToId(IForgeRegistry<E> registry, T object) {
	final Map<T, E> objectToEntryMap = CommonRegistryCallbacks.getObjectToEntryMap(registry);
	final E entry = objectToEntryMap.get(object);

	final BiMap<E, Integer> entryIdMap = CommonRegistryCallbacks.getEntryIdMap(registry);
	return entryIdMap.get(entry);
}
 
源代码21 项目: calcite   文件: MaterializedViewRule.java
/**
 * It swaps the table references and then the column references of the input
 * expressions using the table mapping and the equivalence classes.
 */
protected NodeLineage generateSwapTableColumnReferencesLineage(
    RexBuilder rexBuilder,
    RelMetadataQuery mq,
    RelNode node,
    BiMap<RelTableRef, RelTableRef> tableMapping,
    EquivalenceClasses ec,
    List<RexNode> nodeExprs) {
  final Map<RexNode, Integer> exprsLineage = new HashMap<>();
  final Map<RexNode, Integer> exprsLineageLosslessCasts = new HashMap<>();
  for (int i = 0; i < nodeExprs.size(); i++) {
    final Set<RexNode> s = mq.getExpressionLineage(node, nodeExprs.get(i));
    if (s == null) {
      // Next expression
      continue;
    }
    // We only support project - filter - join, thus it should map to
    // a single expression
    assert s.size() == 1;
    // Rewrite expr. First we swap the table references following the table
    // mapping, then we take first element from the corresponding equivalence class
    final RexNode e = RexUtil.swapTableColumnReferences(rexBuilder,
        s.iterator().next(), tableMapping, ec.getEquivalenceClassesMap());
    exprsLineage.put(e, i);
    if (RexUtil.isLosslessCast(e)) {
      exprsLineageLosslessCasts.put(((RexCall) e).getOperands().get(0), i);
    }
  }
  return new NodeLineage(exprsLineage, exprsLineageLosslessCasts);
}
 
源代码22 项目: vespa   文件: TenantSerializer.java
private BiMap<PublicKey, Principal> developerKeysFromSlime(Inspector array) {
    ImmutableBiMap.Builder<PublicKey, Principal> keys = ImmutableBiMap.builder();
    array.traverse((ArrayTraverser) (__, keyObject) ->
            keys.put(KeyUtils.fromPemEncodedPublicKey(keyObject.field("key").asString()),
                     new SimplePrincipal(keyObject.field("user").asString())));

    return keys.build();
}
 
@Test
public void testGetInstanceEndpoints()
    throws InvalidConfigException {
  Set<String> servers = _helixResourceManager.getAllInstancesForServerTenant(SERVER_TENANT_NAME);
  BiMap<String, String> endpoints = _helixResourceManager.getDataInstanceAdminEndpoints(servers);
  for (int i = 0; i < NUM_INSTANCES; i++) {
    Assert.assertTrue(endpoints.inverse().containsKey("localhost:" + (BASE_SERVER_ADMIN_PORT + i)));
  }
}
 
源代码24 项目: hadoop   文件: ShellBasedIdMapping.java
synchronized private void loadFullGroupMap() throws IOException {
  BiMap<Integer, String> gMap = HashBiMap.create();

  if (OS.startsWith("Mac")) {
    updateMapInternal(gMap, "group", MAC_GET_ALL_GROUPS_CMD, "\\s+",
        staticMapping.gidMapping);
  } else {
    updateMapInternal(gMap, "group", GET_ALL_GROUPS_CMD, ":",
        staticMapping.gidMapping);
  }
  gidNameMap = gMap;
  lastUpdateTime = Time.monotonicNow();
}
 
源代码25 项目: NOVA-Core   文件: ReflectionUtil.java
public static BiMap<Class<? extends Entity>, EntityRegistry.EntityRegistration> getEntityClassRegistrations() {
	try {
		return (BiMap<Class<? extends Entity>, EntityRegistry.EntityRegistration>) ENTITYREGISTRY_CLASSREGISTRATIONS.get(EntityRegistry.instance());
	} catch (IllegalArgumentException | IllegalAccessException ex) {
		return null;
	}
}
 
源代码26 项目: usergrid   文件: SubjectUtils.java
public static Set<String> getOrganizationNames() {
    Subject currentUser = getSubject();
    if ( currentUser == null ) {
        return null;
    }
    if ( !currentUser.hasRole( ROLE_ORGANIZATION_ADMIN ) ) {
        return null;
    }
    BiMap<UUID, String> organizations = getOrganizations();
    if ( organizations == null ) {
        return null;
    }
    return organizations.inverse().keySet();
}
 
源代码27 项目: FreeBuilder   文件: CheckedBiMap.java
@Override
public void addTo(SourceBuilder code) {
  code.addLine("")
      .addLine("private static class %s<K, V> extends %s<%s<K, V>> {",
          TYPE, AbstractSet.class, Map.Entry.class)
      .addLine("")
      .addLine("  private final %s<K, V> biMap;", BiMap.class)
      .addLine("  private final %s<%s<K, V>> set;", Set.class, Map.Entry.class)
      .addLine("  private final %s<K, V> forcePut;", BiConsumer.class)
      .addLine("")
      .addLine("  %s(%s<K, V> biMap, %s<K, V> forcePut) {", TYPE, BiMap.class, BiConsumer.class)
      .addLine("    this.biMap = biMap;")
      .addLine("    this.set = biMap.entrySet();")
      .addLine("    this.forcePut = forcePut;")
      .addLine("  }")
      .addLine("")
      .addLine("  @Override public int size() {")
      .addLine("    return set.size();")
      .addLine("  }")
      .addLine("")
      .addLine("  @Override public %s<%s<K, V>> iterator() {",
          Iterator.class, BiMap.Entry.class)
      .addLine("    return new %s<K, V>(biMap, set.iterator(), forcePut);",
          CheckedEntryIterator.TYPE)
      .addLine("  }")
      .addLine("")
      .addLine("  @Override public boolean contains(Object o) {")
      .addLine("    return set.contains(o);")
      .addLine("  }")
      .addLine("")
      .addLine("  @Override public boolean remove(Object o) {")
      .addLine("    return set.remove(o);")
      .addLine("  }")
      .addLine("")
      .addLine("  @Override public void clear() {")
      .addLine("    set.clear();")
      .addLine("  }")
      .addLine("}");
}
 
源代码28 项目: tutorials   文件: GuavaBiMapUnitTest.java
@Test
public void whenUsingEnumAsKeyInMap_replacesAlreadyPresent() {
    final BiMap<Operation, String> operationStringBiMap = EnumHashBiMap.create(Operation.class);

    operationStringBiMap.put(Operation.ADD, "Add");
    operationStringBiMap.put(Operation.SUBTRACT, "Subtract");
    operationStringBiMap.put(Operation.MULTIPLY, "Multiply");
    operationStringBiMap.put(Operation.DIVIDE, "Divide");

    assertEquals("Divide", operationStringBiMap.get(Operation.DIVIDE));
}
 
源代码29 项目: Quicksql   文件: AbstractMaterializedViewRule.java
/**
 * Rewrites the query using the given view query.
 *
 * <p>The input node is a Scan on the view table and possibly a compensation Filter
 * on top. If a rewriting can be produced, we return that rewriting. If it cannot
 * be produced, we will return null.
 */
protected abstract RelNode rewriteView(RelBuilder relBuilder, RexBuilder rexBuilder,
    RexSimplify simplify, RelMetadataQuery mq, MatchModality matchModality,
    boolean unionRewriting, RelNode input,
    Project topProject, RelNode node,
    Project topViewProject, RelNode viewNode,
    BiMap<RelTableRef, RelTableRef> queryToViewTableMapping,
    EquivalenceClasses queryEC);
 
源代码30 项目: usergrid   文件: SubjectUtils.java
public static BiMap<UUID, String> getOrganizations() {
    Subject currentUser = getSubject();
    if ( !isOrganizationAdmin() ) {
        return null;
    }
    Session session = currentUser.getSession();
    BiMap<UUID, String> organizations = HashBiMap.create();
    Map map = (Map)session.getAttribute( "organizations" );
    organizations.putAll(map);
    return organizations;
}
 
 同包方法