Java Code Examples for com.google.common.collect.ImmutableBiMap#of()

The following examples show how to use com.google.common.collect.ImmutableBiMap#of() . 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: Test.java    From spring-cloud-gray with Apache License 2.0 6 votes vote down vote up
@org.junit.Test
    public void testBind() {
        Map<String, String> args = ImmutableBiMap.of("s", "10", "adf", "a,b,c,d", "apiRes", "#{@apiRes}");
        SpelExpressionParser parser = new SpelExpressionParser();

//        Map<String, Object> properties = ConfigurationUtils.normalize(args, parser, cxt);


//        Object configuration = new St();
//
//        ConfigurationUtils.bind(configuration, properties,
//                "", "", validator,
//                conversionService);
//        System.out.println(configuration);


    }
 
Example 2
Source File: TieredSFCIndexFactory.java    From geowave with Apache License 2.0 6 votes vote down vote up
/**
 * Used to create a Single Tier Index Strategy. For example, this would be used to generate a
 * strategy that has Point type spatial data.
 *
 * @param baseDefinitions the numeric dimensions of the strategy
 * @param maxBitsPerDimension the maximum bits to use for each dimension
 * @param sfc the type of space filling curve (e.g. Hilbert)
 * @return an Index Strategy object with a single tier
 */
public static TieredSFCIndexStrategy createSingleTierStrategy(
    final NumericDimensionDefinition[] baseDefinitions,
    final int[] maxBitsPerDimension,
    final SFCType sfc) {
  final SFCDimensionDefinition[] sfcDimensions =
      new SFCDimensionDefinition[baseDefinitions.length];
  int maxBitsOfPrecision = Integer.MIN_VALUE;
  for (int d = 0; d < baseDefinitions.length; d++) {
    sfcDimensions[d] = new SFCDimensionDefinition(baseDefinitions[d], maxBitsPerDimension[d]);
    maxBitsOfPrecision = Math.max(maxBitsPerDimension[d], maxBitsOfPrecision);
  }

  final SpaceFillingCurve[] orderedSfcs =
      new SpaceFillingCurve[] {SFCFactory.createSpaceFillingCurve(sfcDimensions, sfc)};

  return new TieredSFCIndexStrategy(
      baseDefinitions,
      orderedSfcs,
      ImmutableBiMap.of(0, (byte) maxBitsOfPrecision));
}
 
Example 3
Source File: TieredSFCIndexFactory.java    From geowave with Apache License 2.0 6 votes vote down vote up
/**
 * Used to create a Single Tier Index Strategy. For example, this would be used to generate a
 * strategy that has Point type spatial data.
 *
 * @param dimensionDefs an array of SFC Dimension Definition objects
 * @param sfc the type of space filling curve (e.g. Hilbert)
 * @return an Index Strategy object with a single tier
 */
public static TieredSFCIndexStrategy createSingleTierStrategy(
    final SFCDimensionDefinition[] dimensionDefs,
    final SFCType sfc) {
  final SpaceFillingCurve[] orderedSfcs =
      new SpaceFillingCurve[] {SFCFactory.createSpaceFillingCurve(dimensionDefs, sfc)};
  // unwrap SFC dimension definitions
  final NumericDimensionDefinition[] baseDefinitions =
      new NumericDimensionDefinition[dimensionDefs.length];
  int maxBitsOfPrecision = Integer.MIN_VALUE;
  for (int d = 0; d < baseDefinitions.length; d++) {
    baseDefinitions[d] = dimensionDefs[d].getDimensionDefinition();
    maxBitsOfPrecision = Math.max(dimensionDefs[d].getBitsOfPrecision(), maxBitsOfPrecision);
  }
  return new TieredSFCIndexStrategy(
      baseDefinitions,
      orderedSfcs,
      ImmutableBiMap.of(0, (byte) maxBitsOfPrecision));
}
 
Example 4
Source File: BDDFiniteDomain.java    From batfish with Apache License 2.0 6 votes vote down vote up
/** Use the given variable. */
BDDFiniteDomain(BDDInteger var, Set<V> values) {
  int size = values.size();
  BDD one = var.getFactory().one();
  _var = var;
  _varBits = var.getVars();
  if (size == 0) {
    _valueToBdd = ImmutableBiMap.of();
    _isValidValue = one;
  } else if (size == 1) {
    V value = values.iterator().next();
    _valueToBdd = ImmutableBiMap.of(value, one);
    _isValidValue = one;
  } else {
    int bitsRequired = computeBitsRequired(size);
    checkArgument(bitsRequired <= var.getBitvec().length);
    _valueToBdd = computeValueBdds(var, values);
    _isValidValue = var.leq(size - 1);
  }
  _bddToValue = _valueToBdd.inverse();
}
 
Example 5
Source File: SymlinkTreeTest.java    From buck with Apache License 2.0 6 votes vote down vote up
@Test
public void resolveDuplicateRelativePaths() {
  BuildRuleResolver ruleResolver = new TestActionGraphBuilder();
  tmp.getRoot().resolve("one").toFile().mkdir();
  tmp.getRoot().resolve("two").toFile().mkdir();
  ProjectFilesystem fsOne =
      TestProjectFilesystems.createProjectFilesystem(tmp.getRoot().resolve("one"));
  ProjectFilesystem fsTwo =
      TestProjectFilesystems.createProjectFilesystem(tmp.getRoot().resolve("two"));

  ImmutableBiMap<SourcePath, Path> expected =
      ImmutableBiMap.of(
          FakeSourcePath.of(fsOne, "a/one.a"), Paths.get("a/one.a"),
          FakeSourcePath.of(fsOne, "a/two"), Paths.get("a/two"),
          FakeSourcePath.of(fsTwo, "a/one.a"), Paths.get("a/one-1.a"),
          FakeSourcePath.of(fsTwo, "a/two"), Paths.get("a/two-1"));

  ImmutableBiMap<SourcePath, Path> resolvedDuplicates =
      SymlinkTree.resolveDuplicateRelativePaths(
          ImmutableSortedSet.copyOf(expected.keySet()), ruleResolver.getSourcePathResolver());

  assertThat(resolvedDuplicates, Matchers.equalTo(expected));
}
 
Example 6
Source File: ListRegistrarsAction.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Override
public ImmutableBiMap<String, String> getFieldAliases() {
  return ImmutableBiMap.of(
      "billingId", "billingIdentifier",
      "clientId", "clientIdentifier",
      "premiumNames", "blockPremiumNames");
}
 
Example 7
Source File: DistributedTaskManagerTest.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
void givenTwoTaskManagerIfTheFirstOneIsDownTheSecondOneShouldBeAbleToRunTheRemainingTasks(CountDownLatch countDownLatch) throws Exception {
    try (EventSourcingTaskManager taskManager1 = taskManager();
         EventSourcingTaskManager taskManager2 = taskManager(HOSTNAME_2)) {
        ImmutableBiMap<EventSourcingTaskManager, Hostname> hostNameByTaskManager = ImmutableBiMap.of(taskManager1, HOSTNAME, taskManager2, HOSTNAME_2);
        TaskId firstTask = taskManager1.submit(new MemoryReferenceTask(() -> {
            countDownLatch.await();
            return Task.Result.COMPLETED;
        }));

        awaitUntilTaskHasStatus(firstTask, TaskManager.Status.IN_PROGRESS, taskManager1);

        Hostname nodeRunningFirstTask = taskManager1.getExecutionDetails(firstTask).getRanNode().get();
        Hostname otherNode = getOtherNode(hostNameByTaskManager, nodeRunningFirstTask);
        EventSourcingTaskManager taskManagerRunningFirstTask = hostNameByTaskManager.inverse().get(nodeRunningFirstTask);
        EventSourcingTaskManager otherTaskManager = hostNameByTaskManager.inverse().get(otherNode);

        TaskId taskToExecuteAfterFirstNodeIsDown = taskManagerRunningFirstTask.submit(new CompletedTask());
        taskManagerRunningFirstTask.close();

        awaitAtMostFiveSeconds.untilAsserted(() ->
            assertThat(otherTaskManager.getExecutionDetails(taskToExecuteAfterFirstNodeIsDown).getStatus())
                .isEqualTo(TaskManager.Status.COMPLETED));
        TaskExecutionDetails detailsSecondTask = otherTaskManager.getExecutionDetails(taskToExecuteAfterFirstNodeIsDown);
        assertThat(detailsSecondTask.getRanNode()).contains(otherNode);
    }
}
 
Example 8
Source File: ListTldsAction.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Override
public ImmutableBiMap<String, String> getFieldAliases() {
  return ImmutableBiMap.of(
      "TLD", "tldStr",
      "dns", "dnsPaused",
      "escrow", "escrowEnabled");
}
 
Example 9
Source File: DebugPathSanitizerTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
  debugPathSanitizer =
      new PrefixMapDebugPathSanitizer(
          ".",
          ImmutableBiMap.of(
              Paths.get("/some/absolute/path"),
              "SYMBOLIC_NAME",
              Paths.get("/another/path/with/subdirectories"),
              "OTHER_NAME_WITH_SUFFIX",
              Paths.get("/another/path"),
              "OTHER_NAME"));
}
 
Example 10
Source File: StmtNamespaceContext.java    From yangtools with Eclipse Public License 1.0 5 votes vote down vote up
StmtNamespaceContext(final StmtContext<?, ?, ?> ctx) {
    // QNameModule -> prefix mappings
    final Map<QNameModule, String> qnameToPrefix = ctx.getAllFromNamespace(ModuleQNameToPrefix.class);
    this.moduleToPrefix = qnameToPrefix == null ? ImmutableBiMap.of() : ImmutableBiMap.copyOf(qnameToPrefix);

    // Additional mappings
    final Map<String, StmtContext<?, ?, ?>> imports = ctx.getAllFromNamespace(ImportPrefixToModuleCtx.class);
    if (imports != null) {
        final Map<String, QNameModule> additional = new HashMap<>();
        for (Entry<String, StmtContext<?, ?, ?>> entry : imports.entrySet()) {
            if (!moduleToPrefix.containsValue(entry.getKey())) {
                QNameModule qnameModule = ctx.getFromNamespace(ModuleCtxToModuleQName.class, entry.getValue());
                if (qnameModule == null && ctx.producesDeclared(SubmoduleStatement.class)) {
                    final String moduleName = ctx.getFromNamespace(BelongsToPrefixToModuleName.class,
                        entry.getKey());
                    qnameModule = ctx.getFromNamespace(ModuleNameToModuleQName.class, moduleName);
                }

                if (qnameModule != null) {
                    additional.put(entry.getKey(), qnameModule);
                }
            }
        }
        this.prefixToModule = ImmutableMap.copyOf(additional);
    } else {
        this.prefixToModule = ImmutableMap.of();
    }
}
 
Example 11
Source File: TenantSerializerTest.java    From vespa with Apache License 2.0 5 votes vote down vote up
@Test
public void cloud_tenant() {
    CloudTenant tenant = new CloudTenant(TenantName.from("elderly-lady"),
                                         new BillingInfo("old cat lady", "vespa"),
                                         ImmutableBiMap.of(publicKey, new SimplePrincipal("joe"),
                                                           otherPublicKey, new SimplePrincipal("jane")));
    CloudTenant serialized = (CloudTenant) serializer.tenantFrom(serializer.toSlime(tenant));
    assertEquals(tenant.name(), serialized.name());
    assertEquals(tenant.billingInfo(), serialized.billingInfo());
    assertEquals(tenant.developerKeys(), serialized.developerKeys());
}
 
Example 12
Source File: TieredSFCIndexFactory.java    From geowave with Apache License 2.0 5 votes vote down vote up
/**
 * @param baseDefinitions an array of Numeric Dimension Definitions
 * @param maxBitsPerDimension the max cardinality for the Index Strategy
 * @param sfcType the type of space filling curve (e.g. Hilbert)
 * @param maxEstimatedDuplicatedIds the max number of duplicate SFC IDs
 * @return an Index Strategy object with a tier for every incremental cardinality between the
 *         lowest max bits of precision and 0
 */
public static TieredSFCIndexStrategy createFullIncrementalTieredStrategy(
    final NumericDimensionDefinition[] baseDefinitions,
    final int[] maxBitsPerDimension,
    final SFCType sfcType,
    final Long maxEstimatedDuplicatedIds) {
  if (maxBitsPerDimension.length == 0) {
    final ImmutableBiMap<Integer, Byte> emptyMap = ImmutableBiMap.of();
    return new TieredSFCIndexStrategy(baseDefinitions, new SpaceFillingCurve[] {}, emptyMap);
  }
  int numIndices = Integer.MAX_VALUE;
  for (final int element : maxBitsPerDimension) {
    numIndices = Math.min(numIndices, element + 1);
  }
  final SpaceFillingCurve[] spaceFillingCurves = new SpaceFillingCurve[numIndices];
  final ImmutableBiMap.Builder<Integer, Byte> sfcIndexToTier = ImmutableBiMap.builder();
  for (int sfcIndex = 0; sfcIndex < numIndices; sfcIndex++) {
    final SFCDimensionDefinition[] sfcDimensions =
        new SFCDimensionDefinition[baseDefinitions.length];
    int maxBitsOfPrecision = Integer.MIN_VALUE;
    for (int d = 0; d < baseDefinitions.length; d++) {
      final int bitsOfPrecision = maxBitsPerDimension[d] - (numIndices - sfcIndex - 1);
      maxBitsOfPrecision = Math.max(bitsOfPrecision, maxBitsOfPrecision);
      sfcDimensions[d] = new SFCDimensionDefinition(baseDefinitions[d], bitsOfPrecision);
    }
    sfcIndexToTier.put(sfcIndex, (byte) maxBitsOfPrecision);

    spaceFillingCurves[sfcIndex] = SFCFactory.createSpaceFillingCurve(sfcDimensions, sfcType);
  }
  if ((maxEstimatedDuplicatedIds != null) && (maxEstimatedDuplicatedIds > 0)) {
    return new TieredSFCIndexStrategy(
        baseDefinitions,
        spaceFillingCurves,
        sfcIndexToTier.build(),
        maxEstimatedDuplicatedIds);
  }
  return new TieredSFCIndexStrategy(baseDefinitions, spaceFillingCurves, sfcIndexToTier.build());
}
 
Example 13
Source File: NodeScoreDistributionTest.java    From jpmml-evaluator with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void getProbability(){
	Node node = new LeafNode("ham", null);

	BiMap<String, Node> entityRegistry = ImmutableBiMap.of("1", node);

	NodeScoreDistribution<Double> classification = new NodeScoreDistribution<Double>(new ValueMap<Object, Double>(), node){

		@Override
		public BiMap<String, Node> getEntityRegistry(){
			return entityRegistry;
		}

		@Override
		public List<Node> getDecisionPath(){
			throw new UnsupportedOperationException();
		}
	};

	classification.put("ham", new DoubleValue(0.75d));
	classification.put("spam", new DoubleValue(0.25d));

	assertEquals(ImmutableSet.of("ham", "spam"), classification.getCategories());

	assertEquals((Double)0.75d, classification.getProbability("ham"));
	assertEquals((Double)0.25d, classification.getProbability("spam"));
}
 
Example 14
Source File: FilterResourcesStepTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void valuesAlwaysIncludesFallback() throws IOException, InterruptedException {
  ResourceFilters.Density targetDensity = ResourceFilters.Density.MDPI;
  final String file = "somefile.xml";
  Path resDir = Paths.get("res/foo/bar");
  Path resOutDir = Paths.get("res-out");

  ProjectFilesystem filesystem = new FakeProjectFilesystem();
  filesystem.mkdirs(resDir);
  filesystem.createNewFile(resDir.resolve("values").resolve(file));
  filesystem.createNewFile(
      resDir.resolve(String.format("values-%s", targetDensity)).resolve(file));

  FilterResourcesSteps filterResourcesSteps =
      new FilterResourcesSteps(
          filesystem,
          ImmutableBiMap.of(resDir, resOutDir),
          /* filterByDPI */ true,
          /* enableStringWhitelisting */ false,
          /* whitelistedStringDirs */ ImmutableSet.of(),
          /* locales */ ImmutableSet.of(),
          /* localizedStringFileName */ Optional.empty(),
          DefaultFilteredDirectoryCopier.getInstance(),
          ImmutableSet.of(targetDensity),
          FilterResourcesSteps.DefaultDrawableFinder.getInstance(),
          /* imageScaler */ null);
  filterResourcesSteps.getCopyStep().execute(null);
  filterResourcesSteps.getScaleStep().execute(null);

  assertThat(
      filesystem,
      ProjectFilesystemMatchers.pathExists(resOutDir.resolve("values").resolve(file)));
  assertThat(
      filesystem,
      ProjectFilesystemMatchers.pathExists(
          resOutDir.resolve(String.format("values-%s", targetDensity)).resolve(file)));
}
 
Example 15
Source File: PreprocessorFlagsTest.java    From buck with Apache License 2.0 5 votes vote down vote up
@Test
public void flagsAreSanitized() {
  SourcePathRuleFinder ruleFinder = new TestActionGraphBuilder();
  BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
  FakeFileHashCache hashCache = FakeFileHashCache.createFromStrings(ImmutableMap.of());
  BuildRule fakeBuildRule = new FakeBuildRule(target);

  class TestData {
    public RuleKey generate(String prefix) {
      DebugPathSanitizer sanitizer =
          new PrefixMapDebugPathSanitizer(".", ImmutableBiMap.of(Paths.get(prefix), "A"));

      CxxToolFlags flags =
          CxxToolFlags.explicitBuilder()
              .addAllPlatformFlags(
                  SanitizedArg.from(
                      sanitizer.sanitizer(Optional.empty()),
                      ImmutableList.of("-I" + prefix + "/foo")))
              .addAllRuleFlags(
                  SanitizedArg.from(
                      sanitizer.sanitizer(Optional.empty()),
                      ImmutableList.of("-I" + prefix + "/bar")))
              .build();

      DefaultRuleKeyFactory.Builder<HashCode> builder =
          new TestDefaultRuleKeyFactory(hashCache, ruleFinder)
              .newBuilderForTesting(fakeBuildRule);
      builder.setReflectively(
          "flags", PreprocessorFlags.builder().setOtherFlags(flags).build());
      return builder.build(RuleKey::new);
    }
  }

  TestData testData = new TestData();
  Assert.assertEquals(testData.generate("something"), testData.generate("different"));
}
 
Example 16
Source File: CxxLinkTest.java    From buck with Apache License 2.0 4 votes vote down vote up
@Test
public void sanitizedPathsInFlagsDoNotAffectRuleKey() {
  SourcePathRuleFinder ruleFinder = new TestActionGraphBuilder();
  BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
  ProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
  DefaultRuleKeyFactory ruleKeyFactory =
      new TestDefaultRuleKeyFactory(
          FakeFileHashCache.createFromStrings(
              ImmutableMap.of(
                  "ld", Strings.repeat("0", 40),
                  "a.o", Strings.repeat("a", 40),
                  "b.o", Strings.repeat("b", 40),
                  "libc.a", Strings.repeat("c", 40),
                  "different", Strings.repeat("d", 40))),
          ruleFinder);

  // Set up a map to sanitize the differences in the flags.
  DebugPathSanitizer sanitizer1 =
      new PrefixMapDebugPathSanitizer(".", ImmutableBiMap.of(Paths.get("something"), "A"));
  DebugPathSanitizer sanitizer2 =
      new PrefixMapDebugPathSanitizer(".", ImmutableBiMap.of(Paths.get("different"), "A"));

  // Generate a rule with a path we need to sanitize to a consistent value.
  ImmutableList<Arg> args1 =
      ImmutableList.of(
          SanitizedArg.create(sanitizer1.sanitizer(Optional.empty()), "-Lsomething/foo"));

  RuleKey ruleKey1 =
      ruleKeyFactory.build(
          new CxxLink(
              target,
              projectFilesystem,
              ruleFinder,
              TestCellPathResolver.get(projectFilesystem),
              DEFAULT_LINKER,
              DEFAULT_OUTPUT,
              ImmutableMap.of(),
              args1,
              Optional.empty(),
              Optional.empty(),
              /* cacheable */ true,
              /* thinLto */ false,
              /* fatLto */ false));

  // Generate another rule with a different path we need to sanitize to the
  // same consistent value as above.
  ImmutableList<Arg> args2 =
      ImmutableList.of(
          SanitizedArg.create(sanitizer2.sanitizer(Optional.empty()), "-Ldifferent/foo"));

  RuleKey ruleKey2 =
      ruleKeyFactory.build(
          new CxxLink(
              target,
              projectFilesystem,
              ruleFinder,
              TestCellPathResolver.get(projectFilesystem),
              DEFAULT_LINKER,
              DEFAULT_OUTPUT,
              ImmutableMap.of(),
              args2,
              Optional.empty(),
              Optional.empty(),
              /* cacheable */ true,
              /* thinLto */ false,
              /* fatLto */ false));

  assertEquals(ruleKey1, ruleKey2);
}
 
Example 17
Source File: CxxCompileStepIntegrationTest.java    From buck with Apache License 2.0 4 votes vote down vote up
private void assertCompDir(Optional<String> failure) throws Exception {
  ProjectFilesystem filesystem = TestProjectFilesystems.createProjectFilesystem(tmp.getRoot());
  CxxPlatform platform =
      CxxPlatformUtils.build(new CxxBuckConfig(FakeBuckConfig.builder().build()));

  // Build up the paths to various files the archive step will use.
  BuildRuleResolver resolver = new TestActionGraphBuilder();
  Compiler compiler =
      platform.getCc().resolve(resolver, UnconfiguredTargetConfiguration.INSTANCE);
  ImmutableList<String> compilerCommandPrefix =
      compiler.getCommandPrefix(resolver.getSourcePathResolver());
  Path output = filesystem.resolve(Paths.get("output.o"));
  Path depFile = filesystem.resolve(Paths.get("output.dep"));
  Path relativeInput = Paths.get("input.c");
  Path input = filesystem.resolve(relativeInput);
  filesystem.writeContentsToPath("int main() {}", relativeInput);
  Path scratchDir = filesystem.getPath("scratchDir");
  filesystem.mkdirs(scratchDir);

  ImmutableList.Builder<String> compilerArguments = ImmutableList.builder();
  compilerArguments.add("-g");

  DebugPathSanitizer sanitizer = new PrefixMapDebugPathSanitizer(".", ImmutableBiMap.of());

  // Build an archive step.
  CxxPreprocessAndCompileStep step =
      new CxxPreprocessAndCompileStep(
          filesystem,
          CxxPreprocessAndCompileStep.Operation.PREPROCESS_AND_COMPILE,
          output,
          Optional.of(depFile),
          relativeInput,
          CxxSource.Type.C,
          new CxxPreprocessAndCompileStep.ToolCommand(
              compilerCommandPrefix, compilerArguments.build(), ImmutableMap.of()),
          resolver.getSourcePathResolver(),
          HeaderPathNormalizer.empty(),
          sanitizer,
          scratchDir,
          true,
          ImmutableList.of(),
          compiler,
          Optional.empty());

  // Execute the archive step and verify it ran successfully.
  ExecutionContext executionContext = TestExecutionContext.newInstance();
  TestConsole console = (TestConsole) executionContext.getConsole();
  int exitCode = step.execute(executionContext).getExitCode();
  if (failure.isPresent()) {
    assertNotEquals("compile step succeeded", 0, exitCode);
    assertThat(
        console.getTextWrittenToStdErr(),
        console.getTextWrittenToStdErr(),
        Matchers.containsString(failure.get()));
  } else {
    assertEquals("compile step failed: " + console.getTextWrittenToStdErr(), 0, exitCode);
    // Verify that we find the expected compilation dir embedded in the file.
    String contents = new String(Files.readAllBytes(output));
    assertThat(contents, Matchers.containsString(sanitizer.getCompilationDirectory()));
  }

  // Cleanup.
  Files.delete(input);
  Files.deleteIfExists(output);
}
 
Example 18
Source File: BiMapSourceTest.java    From FreeBuilder with Apache License 2.0 4 votes vote down vote up
private static GeneratedBuilder builder() {
  GenericTypeElementImpl bimap = newTopLevelGenericType("com.google.common.collect.BiMap");
  GenericTypeMirrorImpl mapIntString = bimap.newMirror(INTEGER, STRING);
  QualifiedName person = QualifiedName.of("com.example", "Person");
  QualifiedName generatedBuilder = QualifiedName.of("com.example", "Person_Builder");

  Datatype datatype = new Datatype.Builder()
      .setBuilder(person.nestedType("Builder").withParameters())
      .setExtensible(true)
      .setBuilderFactory(BuilderFactory.NO_ARGS_CONSTRUCTOR)
      .setBuilderSerializable(false)
      .setGeneratedBuilder(generatedBuilder.withParameters())
      .setInterfaceType(false)
      .setPartialType(generatedBuilder.nestedType("Partial").withParameters())
      .setPropertyEnum(generatedBuilder.nestedType("Property").withParameters())
      .setRebuildableType(generatedBuilder.nestedType("Rebuildable").withParameters())
      .setType(person.withParameters())
      .setValueType(generatedBuilder.nestedType("Value").withParameters())
      .build();
  Property name = new Property.Builder()
      .setAllCapsName("NAME")
      .setBoxedType(mapIntString)
      .setCapitalizedName("Name")
      .setFullyCheckedCast(true)
      .setGetterName("name")
      .setName("name")
      .setType(mapIntString)
      .setUsingBeanConvention(false)
      .build();

  return new GeneratedBuilder(datatype, ImmutableBiMap.of(
      name, new BiMapProperty(
          datatype,
          name,
          false,
          INTEGER,
          Optional.of(INT),
          STRING,
          Optional.empty(),
          consumer(wildcardSuper(mapIntString)))));
}
 
Example 19
Source File: CloudTenant.java    From vespa with Apache License 2.0 4 votes vote down vote up
/** Creates a tenant with the given name, provided it passes validation. */
public static CloudTenant create(TenantName tenantName, BillingInfo billingInfo) {
    return new CloudTenant(requireName(tenantName),
                           Objects.requireNonNull(billingInfo),
                           ImmutableBiMap.of());
}
 
Example 20
Source File: ListObjectsAction.java    From nomulus with Apache License 2.0 2 votes vote down vote up
/**
 * Returns an {@link ImmutableBiMap} that maps any field name aliases to the actual field names.
 *
 * <p>Users can select aliased fields for display using either the original name or the alias.  By
 * default, aliased fields will use the alias name as the header instead of the original name.
 */
ImmutableBiMap<String, String> getFieldAliases() {
  return ImmutableBiMap.of();
}