Java Code Examples for com.google.common.collect.Sets#immutableEnumSet()

The following examples show how to use com.google.common.collect.Sets#immutableEnumSet() . 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: RexSimplify.java    From Bats with Apache License 2.0 6 votes vote down vote up
SafeRexVisitor() {
    Set<SqlKind> safeOps = EnumSet.noneOf(SqlKind.class);

    safeOps.addAll(SqlKind.COMPARISON);
    safeOps.add(SqlKind.PLUS);
    safeOps.add(SqlKind.MINUS);
    safeOps.add(SqlKind.TIMES);
    safeOps.add(SqlKind.IS_FALSE);
    safeOps.add(SqlKind.IS_NOT_FALSE);
    safeOps.add(SqlKind.IS_TRUE);
    safeOps.add(SqlKind.IS_NOT_TRUE);
    safeOps.add(SqlKind.IS_NULL);
    safeOps.add(SqlKind.IS_NOT_NULL);
    safeOps.add(SqlKind.IN);
    safeOps.add(SqlKind.NOT_IN);
    safeOps.add(SqlKind.OR);
    safeOps.add(SqlKind.AND);
    safeOps.add(SqlKind.NOT);
    safeOps.add(SqlKind.CASE);
    safeOps.add(SqlKind.LIKE);
    safeOps.add(SqlKind.COALESCE);
    this.safeOps = Sets.immutableEnumSet(safeOps);
}
 
Example 2
Source File: BgpSessionProperties.java    From batfish with Apache License 2.0 6 votes vote down vote up
private BgpSessionProperties(
    Collection<Type> addressFamilies,
    Map<Type, RouteExchange> routeExchangeSettings,
    long tailAs,
    long headAs,
    Ip tailIp,
    Ip headIp,
    SessionType sessionType,
    ConfedSessionType confedType) {
  _addressFamilies = Sets.immutableEnumSet(addressFamilies);
  _routeExchangeSettings = ImmutableMap.copyOf(routeExchangeSettings);
  _tailAs = tailAs;
  _headAs = headAs;
  _tailIp = tailIp;
  _headIp = headIp;
  _sessionType = sessionType;
  _confedSessionType = confedType;
}
 
Example 3
Source File: HBaseUtils.java    From geowave with Apache License 2.0 5 votes vote down vote up
public static ImmutableSet<ServerOpScope> stringToScopes(final String value) {
  final String[] scopes = value.split(",");
  return Sets.immutableEnumSet(
      Iterables.transform(Arrays.asList(scopes), new Function<String, ServerOpScope>() {

        @Override
        public ServerOpScope apply(final String input) {
          return ServerOpScope.valueOf(input);
        }
      }));
}
 
Example 4
Source File: HotColdSolverTest.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testSameTempNoChanges()
{
	final HotColdSolver solver = createHotColdSolver();
	final WorldPoint testedPoint = new WorldPoint(2851, 2955, 0);
	final Set<HotColdLocation> foundLocations = Sets.immutableEnumSet(
		HotColdLocation.KARAMJA_KHARAZI_NE,
		HotColdLocation.KARAMJA_KHARAZI_SW);

	testSolver(solver, testedPoint, RESPONSE_TEXT_VERY_HOT, foundLocations);
	testSolver(solver, testedPoint, RESPONSE_TEXT_VERY_HOT_SAME_TEMP, foundLocations);
}
 
Example 5
Source File: RexSimplify.java    From calcite with Apache License 2.0 5 votes vote down vote up
SafeRexVisitor() {
  Set<SqlKind> safeOps = EnumSet.noneOf(SqlKind.class);

  safeOps.addAll(SqlKind.COMPARISON);
  safeOps.add(SqlKind.PLUS_PREFIX);
  safeOps.add(SqlKind.MINUS_PREFIX);
  safeOps.add(SqlKind.PLUS);
  safeOps.add(SqlKind.MINUS);
  safeOps.add(SqlKind.TIMES);
  safeOps.add(SqlKind.IS_FALSE);
  safeOps.add(SqlKind.IS_NOT_FALSE);
  safeOps.add(SqlKind.IS_TRUE);
  safeOps.add(SqlKind.IS_NOT_TRUE);
  safeOps.add(SqlKind.IS_NULL);
  safeOps.add(SqlKind.IS_NOT_NULL);
  safeOps.add(SqlKind.IS_DISTINCT_FROM);
  safeOps.add(SqlKind.IS_NOT_DISTINCT_FROM);
  safeOps.add(SqlKind.IN);
  safeOps.add(SqlKind.NOT_IN);
  safeOps.add(SqlKind.OR);
  safeOps.add(SqlKind.AND);
  safeOps.add(SqlKind.NOT);
  safeOps.add(SqlKind.CASE);
  safeOps.add(SqlKind.LIKE);
  safeOps.add(SqlKind.COALESCE);
  safeOps.add(SqlKind.TRIM);
  safeOps.add(SqlKind.LTRIM);
  safeOps.add(SqlKind.RTRIM);
  safeOps.add(SqlKind.BETWEEN);
  safeOps.add(SqlKind.CEIL);
  safeOps.add(SqlKind.FLOOR);
  safeOps.add(SqlKind.REVERSE);
  safeOps.add(SqlKind.TIMESTAMP_ADD);
  safeOps.add(SqlKind.TIMESTAMP_DIFF);
  this.safeOps = Sets.immutableEnumSet(safeOps);
}
 
Example 6
Source File: HotColdSolverTest.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testNarrowToFindSolutions()
{
	final HotColdSolver solver = createHotColdSolver();
	final Set<HotColdLocation> firstLocationsSet = Sets.immutableEnumSet(
		HotColdLocation.FELDIP_HILLS_GNOME_GLITER,
		HotColdLocation.FELDIP_HILLS_RANTZ,
		HotColdLocation.FELDIP_HILLS_RED_CHIN,
		HotColdLocation.KARAMJA_KHARAZI_NE,
		HotColdLocation.KARAMJA_CRASH_ISLAND);
	final Set<HotColdLocation> secondLocationsSet = firstLocationsSet.stream()
		.filter(location -> location != HotColdLocation.FELDIP_HILLS_GNOME_GLITER
			&& location != HotColdLocation.FELDIP_HILLS_RANTZ)
		.collect(Collectors.toSet());
	final Set<HotColdLocation> thirdLocationSet = secondLocationsSet.stream()
		.filter(location -> location != HotColdLocation.FELDIP_HILLS_RED_CHIN)
		.collect(Collectors.toSet());
	final Set<HotColdLocation> finalLocation = thirdLocationSet.stream()
		.filter(location -> location != HotColdLocation.KARAMJA_CRASH_ISLAND)
		.collect(Collectors.toSet());

	testSolver(solver, new WorldPoint(2711, 2803, 0), RESPONSE_TEXT_COLD, firstLocationsSet);
	testSolver(solver, new WorldPoint(2711, 2802, 0), RESPONSE_TEXT_COLD_SAME_TEMP, secondLocationsSet);
	testSolver(solver, new WorldPoint(2716, 2802, 0), RESPONSE_TEXT_COLD_WARMER, thirdLocationSet);
	testSolver(solver, new WorldPoint(2739, 2808, 0), RESPONSE_TEXT_COLD_WARMER, thirdLocationSet);
	testSolver(solver, new WorldPoint(2810, 2757, 0), RESPONSE_TEXT_COLD_COLDER, finalLocation);
}
 
Example 7
Source File: HotColdSolverTest.java    From plugins with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testOneStepSolution()
{
	final Set<HotColdLocation> foundLocation = Sets.immutableEnumSet(HotColdLocation.KARAMJA_KHARAZI_NE);

	testSolver(createHotColdSolver(), new WorldPoint(2852, 2992, 0), RESPONSE_TEXT_VERY_HOT, foundLocation);
}
 
Example 8
Source File: PerRolePermissions.java    From centraldogma with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an instance.
 */
@JsonCreator
public PerRolePermissions(@JsonProperty("owner") Iterable<Permission> owner,
                          @JsonProperty("member") Iterable<Permission> member,
                          @JsonProperty("guest") Iterable<Permission> guest) {
    this.owner = Sets.immutableEnumSet(requireNonNull(owner, "owner"));
    this.member = Sets.immutableEnumSet(requireNonNull(member, "member"));
    this.guest = Sets.immutableEnumSet(requireNonNull(guest, "guest"));
}
 
Example 9
Source File: Compilation.java    From compile-testing with Apache License 2.0 5 votes vote down vote up
ImmutableList<Diagnostic<? extends JavaFileObject>> diagnosticsOfKind(Kind kind, Kind... more) {
  ImmutableSet<Kind> kinds = Sets.immutableEnumSet(kind, more);
  return diagnostics()
      .stream()
      .filter(diagnostic -> kinds.contains(diagnostic.getKind()))
      .collect(toImmutableList());
}
 
Example 10
Source File: RetryRule.java    From armeria with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a newly created {@link RetryRuleBuilder} with the specified {@link HttpMethod}s.
 */
static RetryRuleBuilder builder(Iterable<HttpMethod> methods) {
    requireNonNull(methods, "methods");
    checkArgument(!Iterables.isEmpty(methods), "method can't be empty.");
    final ImmutableSet<HttpMethod> httpMethods = Sets.immutableEnumSet(methods);
    return builder(headers -> httpMethods.contains(headers.method()));
}
 
Example 11
Source File: HotColdSolverTest.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testOneStepSolution()
{
	final Set<HotColdLocation> foundLocation = Sets.immutableEnumSet(HotColdLocation.KARAMJA_KHARAZI_NE);

	testSolver(createHotColdSolver(), new WorldPoint(2852, 2992, 0), RESPONSE_TEXT_VERY_HOT, foundLocation);
}
 
Example 12
Source File: HotColdSolverTest.java    From runelite with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Test
public void testNarrowToFindSolutions()
{
	final HotColdSolver solver = createHotColdSolver();
	final Set<HotColdLocation> firstLocationsSet = Sets.immutableEnumSet(
		HotColdLocation.FELDIP_HILLS_GNOME_GLITER,
		HotColdLocation.FELDIP_HILLS_RANTZ,
		HotColdLocation.FELDIP_HILLS_RED_CHIN,
		HotColdLocation.KARAMJA_KHARAZI_NE,
		HotColdLocation.KARAMJA_CRASH_ISLAND);
	final Set<HotColdLocation> secondLocationsSet = firstLocationsSet.stream()
		.filter(location -> location != HotColdLocation.FELDIP_HILLS_GNOME_GLITER
			&& location != HotColdLocation.FELDIP_HILLS_RANTZ)
		.collect(Collectors.toSet());
	final Set<HotColdLocation> thirdLocationSet = secondLocationsSet.stream()
		.filter(location -> location != HotColdLocation.FELDIP_HILLS_RED_CHIN)
		.collect(Collectors.toSet());
	final Set<HotColdLocation> finalLocation = thirdLocationSet.stream()
		.filter(location -> location != HotColdLocation.KARAMJA_CRASH_ISLAND)
		.collect(Collectors.toSet());

	testSolver(solver, new WorldPoint(2711, 2803, 0), RESPONSE_TEXT_COLD, firstLocationsSet);
	testSolver(solver, new WorldPoint(2711, 2802, 0), RESPONSE_TEXT_COLD_SAME_TEMP, secondLocationsSet);
	testSolver(solver, new WorldPoint(2716, 2802, 0), RESPONSE_TEXT_COLD_WARMER, thirdLocationSet);
	testSolver(solver, new WorldPoint(2739, 2808, 0), RESPONSE_TEXT_COLD_WARMER, thirdLocationSet);
	testSolver(solver, new WorldPoint(2810, 2757, 0), RESPONSE_TEXT_COLD_COLDER, finalLocation);
}
 
Example 13
Source File: RetryRuleWithContent.java    From armeria with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a newly created {@link RetryRuleWithContentBuilder} with the specified {@link HttpMethod}s.
 */
static <T extends Response> RetryRuleWithContentBuilder<T> builder(Iterable<HttpMethod> methods) {
    requireNonNull(methods, "methods");
    checkArgument(!Iterables.isEmpty(methods), "methods can't be empty.");
    final ImmutableSet<HttpMethod> httpMethods = Sets.immutableEnumSet(methods);
    return builder(headers -> httpMethods.contains(headers.method()));
}
 
Example 14
Source File: DocumentFieldDescriptor.java    From metasfresh-webui-api-legacy with GNU General Public License v3.0 4 votes vote down vote up
private DocumentFieldDescriptor(final Builder builder)
{
	fieldName = Preconditions.checkNotNull(builder.fieldName, "name is null");
	caption = builder.getCaption();
	description = builder.getDescription();
	detailId = builder.getDetailId();

	key = builder.isKey();
	calculated = builder.isCalculated();

	parentLink = builder.parentLink;
	parentLinkFieldName = builder.parentLinkFieldName;

	widgetType = builder.getWidgetType();
	fieldMaxLength = builder.getFieldMaxLength();

	widgetSize = builder.getWidgetSize();
	allowShowPassword = builder.isAllowShowPassword();
	buttonActionDescriptor = builder.getButtonActionDescriptor();
	barcodeScannerType = builder.getBarcodeScannerType();
	valueClass = builder.getValueClass();

	lookupDescriptorProvider = builder.getLookupDescriptorProvider();
	supportZoomInto = builder.isSupportZoomInto();

	defaultValueExpression = Preconditions.checkNotNull(builder.defaultValueExpression, "defaultValueExpression not null");

	virtualField = builder.isVirtualField();
	virtualFieldValueProvider = builder.getVirtualFieldValueProvider();

	characteristics = Sets.immutableEnumSet(builder.characteristics);
	readonlyLogic = builder.getReadonlyLogicEffective();
	alwaysUpdateable = builder.alwaysUpdateable;
	displayLogic = builder.displayLogic;
	mandatoryLogic = builder.getMandatoryLogicEffective();

	dataBinding = builder.getDataBinding();

	dependencies = builder.buildDependencies();

	callouts = builder.buildCallouts();

	//
	// Default filtering
	defaultFilterInfo = builder.defaultFilterInfo;
}
 
Example 15
Source File: UserClient.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
@Override
  protected void validateHandshake(BitToUserHandshake inbound) throws RpcException {
//    logger.debug("Handling handshake from bit to user. {}", inbound);
    if (inbound.getStatus() != HandshakeStatus.SUCCESS) {
      final String errMsg = String.format("Status: %s, Error Id: %s, Error message: %s",
          inbound.getStatus(), inbound.getErrorId(), inbound.getErrorMessage());
      logger.error(errMsg);
      throw new RpcException(errMsg, inbound.getStatus().toString(), inbound.getErrorId());
    }

    // Successful connection...
    if (inbound.hasServerInfos()) {
      serverInfos = inbound.getServerInfos();
    }
    supportedMethods = Sets.immutableEnumSet(inbound.getSupportedMethodsList());
    // Older servers don't return record batch format: assume pre-1.4 servers
    RecordBatchFormat recordBatchFormat = inbound.hasRecordBatchFormat() ? inbound.getRecordBatchFormat() : RecordBatchFormat.DREMIO_0_9;

    switch(recordBatchFormat) {
    case DREMIO_1_4:
      break;

    case DREMIO_0_9:
    {
      /*
       * From Dremio 1.4 onwards we have moved to Little Endian Decimal format. We need to
       * add a new decoder in the netty pipeline when talking to old (1.3 and less) Dremio
       * servers.
       */
      final BufferAllocator bcAllocator = connection.getAllocator()
          .newChildAllocator("dremio09-backward", 0, Long.MAX_VALUE);
      logger.debug("Adding dremio 09 backwards compatibility decoder");
      connection.getChannel()
        .pipeline()
        .addAfter(PROTOCOL_DECODER, UserRpcUtils.DREMIO09_COMPATIBILITY_ENCODER,
          new BackwardsCompatibilityDecoder(bcAllocator, new Dremio09BackwardCompatibilityHandler(bcAllocator)));
      }
      break;

    case UNKNOWN:
    default:
      throw new RpcException("Unsupported record batch format: " + recordBatchFormat);
    }
  }
 
Example 16
Source File: PosixAttributeProvider.java    From jimfs with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public ImmutableMap<String, ?> defaultValues(Map<String, ?> userProvidedDefaults) {
  Object userProvidedGroup = userProvidedDefaults.get("posix:group");

  UserPrincipal group = DEFAULT_GROUP;
  if (userProvidedGroup != null) {
    if (userProvidedGroup instanceof String) {
      group = createGroupPrincipal((String) userProvidedGroup);
    } else {
      throw new IllegalArgumentException(
          "invalid type "
              + userProvidedGroup.getClass().getName()
              + " for attribute 'posix:group': should be one of "
              + String.class
              + " or "
              + GroupPrincipal.class);
    }
  }

  Object userProvidedPermissions = userProvidedDefaults.get("posix:permissions");

  Set<PosixFilePermission> permissions = DEFAULT_PERMISSIONS;
  if (userProvidedPermissions != null) {
    if (userProvidedPermissions instanceof String) {
      permissions =
          Sets.immutableEnumSet(
              PosixFilePermissions.fromString((String) userProvidedPermissions));
    } else if (userProvidedPermissions instanceof Set) {
      permissions = toPermissions((Set<?>) userProvidedPermissions);
    } else {
      throw new IllegalArgumentException(
          "invalid type "
              + userProvidedPermissions.getClass().getName()
              + " for attribute 'posix:permissions': should be one of "
              + String.class
              + " or "
              + Set.class);
    }
  }

  return ImmutableMap.of(
      "posix:group", group,
      "posix:permissions", permissions);
}
 
Example 17
Source File: AtlasDataBindingMergeArtifactsTransform.java    From atlas with Apache License 2.0 4 votes vote down vote up
@NonNull
@Override
public Set<QualifiedContent.Scope> getReferencedScopes() {
    return Sets.immutableEnumSet(QualifiedContent.Scope.SUB_PROJECTS,
            QualifiedContent.Scope.EXTERNAL_LIBRARIES);
}
 
Example 18
Source File: InlineRTransform.java    From shrinker with Apache License 2.0 4 votes vote down vote up
@Override
public Set<? super QualifiedContent.Scope> getReferencedScopes() {
    if (config.inlineR) // empty
        return ImmutableSet.of();
    return Sets.immutableEnumSet(QualifiedContent.Scope.PROJECT);
}
 
Example 19
Source File: CambridgeTraceReader.java    From caffeine with Apache License 2.0 4 votes vote down vote up
@Override
public Set<Characteristic> characteristics() {
  return Sets.immutableEnumSet(WEIGHTED);
}
 
Example 20
Source File: ImmutableHolidayCalendar.java    From Strata with Apache License 2.0 3 votes vote down vote up
/**
 * Obtains an instance from a set of holiday dates and weekend days.
 * <p>
 * The holiday dates will be extracted into a set with duplicates ignored.
 * The minimum supported date for query is the start of the year of the earliest holiday.
 * The maximum supported date for query is the end of the year of the latest holiday.
 * <p>
 * The weekend days may both be the same.
 * 
 * @param id  the identifier
 * @param holidays  the set of holiday dates
 * @param firstWeekendDay  the first weekend day
 * @param secondWeekendDay  the second weekend day, may be same as first
 * @return the holiday calendar
 */
public static ImmutableHolidayCalendar of(
    HolidayCalendarId id,
    Iterable<LocalDate> holidays,
    DayOfWeek firstWeekendDay,
    DayOfWeek secondWeekendDay) {

  ImmutableSet<DayOfWeek> weekendDays = Sets.immutableEnumSet(firstWeekendDay, secondWeekendDay);
  return of(id, ImmutableSortedSet.copyOf(holidays), weekendDays, ImmutableSet.of());
}