Java Code Examples for java.util.EnumSet#equals()

The following examples show how to use java.util.EnumSet#equals() . 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: IssueRegistry.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns all available issues of a given scope (regardless of whether
 * they are actually enabled for a given configuration etc)
 *
 * @param scope the applicable scope set
 * @return a list of issues
 */
@NonNull
protected List<Issue> getIssuesForScope(@NonNull EnumSet<Scope> scope) {
    List<Issue> list = sScopeIssues.get(scope);
    if (list == null) {
        List<Issue> issues = getIssues();
        if (scope.equals(Scope.ALL)) {
            list = issues;
        } else {
            list = new ArrayList<Issue>(getIssueCapacity(scope));
            for (Issue issue : issues) {
                // Determine if the scope matches
                if (issue.getImplementation().isAdequate(scope)) {
                    list.add(issue);
                }
            }
        }
        sScopeIssues.put(scope, list);
    }

    return list;
}
 
Example 2
Source File: BuiltinIssueRegistry.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected int getIssueCapacity(@NonNull EnumSet<Scope> scope) {
    if (scope.equals(Scope.ALL)) {
        return getIssues().size();
    } else {
        int initialSize = 12;
        if (scope.contains(Scope.RESOURCE_FILE)) {
            initialSize += 75;
        } else if (scope.contains(Scope.ALL_RESOURCE_FILES)) {
            initialSize += 10;
        }

        if (scope.contains(Scope.JAVA_FILE)) {
            initialSize += 55;
        } else if (scope.contains(Scope.CLASS_FILE)) {
            initialSize += 15;
        } else if (scope.contains(Scope.MANIFEST)) {
            initialSize += 30;
        } else if (scope.contains(Scope.GRADLE_FILE)) {
            initialSize += 5;
        }
        return initialSize;
    }
}
 
Example 3
Source File: CodeCacheOptions.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public CodeCacheOptions mapOptions(EnumSet<BlobType> involvedCodeHeaps) {
    if (involvedCodeHeaps.isEmpty()
            || involvedCodeHeaps.equals(NON_SEGMENTED_HEAPS)
            || involvedCodeHeaps.equals(ALL_SEGMENTED_HEAPS)) {
        return this;
    } else if (involvedCodeHeaps.equals(SEGMENTED_HEAPS_WO_PROFILED)) {
        return new CodeCacheOptions(reserved, nonNmethods,
                profiled + nonProfiled, 0L);
    } else if (involvedCodeHeaps.equals(ONLY_NON_METHODS_HEAP)) {
        return new CodeCacheOptions(reserved, nonNmethods + profiled
                + nonProfiled, 0L, 0L);
    } else {
        throw new Error("Test bug: unexpected set of code heaps involved "
                + "into test.");
    }
}
 
Example 4
Source File: DeviceManagerImpl.java    From floodlight_with_topoguard with Apache License 2.0 6 votes vote down vote up
/**
 * Allocate a new {@link ClassState} object for the class
 * @param clazz the class to use for the state
 */
public ClassState(IEntityClass clazz) {
    EnumSet<DeviceField> keyFields = clazz.getKeyFields();
    EnumSet<DeviceField> primaryKeyFields =
            entityClassifier.getKeyFields();
    boolean keyFieldsMatchPrimary =
            primaryKeyFields.equals(keyFields);

    if (!keyFieldsMatchPrimary)
        classIndex = new DeviceUniqueIndex(keyFields);

    secondaryIndexMap =
            new HashMap<EnumSet<DeviceField>, DeviceIndex>();
    for (EnumSet<DeviceField> fields : perClassIndices) {
        secondaryIndexMap.put(fields,
                              new DeviceMultiIndex(fields));
    }
}
 
Example 5
Source File: MoCClientTickHandler.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData)
{
    if (type.equals(EnumSet.of(TickType.CLIENT)))
    {
        GuiScreen curScreen = Minecraft.getMinecraft().currentScreen;
        if (curScreen != null)
        {
            onTickInGui(curScreen);
        }
        else
        {
            onTickInGame();
        }
    }

}
 
Example 6
Source File: PlayerTickHandler.java    From HexxitGear with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
    if (type.equals(EnumSet.of(TickType.PLAYER))) {
        for (Object tick : tickData) {
            if (tick instanceof EntityPlayer) {
                EntityPlayer player = (EntityPlayer) tick;
                if (tickCounter > 20) {
                    ArmorSet.getMatchingSet(player);
                    tickCounter = 0;
                }
                tickCounter++;

                if (ArmorSet.getPlayerArmorSet(player.username) != null) {
                    ArmorSet armorSet = ArmorSet.getPlayerArmorSet(player.username);
                    armorSet.applyBuffs(player);
                }

                // We run this outside of the check for an armorset just incase a player takes off armor mid ability
                AbilityHandler bh = AbilityHandler.getPlayerAbilityHandler(player.username);
                if (bh != null) {
                    bh.onTick(player);
                }
            }
        }
    }
}
 
Example 7
Source File: ProtoAccountDataSerializerTest.java    From swellrt with Apache License 2.0 5 votes vote down vote up
private boolean compareCapability(Capability c1, Capability c2) {
  if (c1.getEventType() != c2.getEventType() ||
      !c1.getFilter().equals(c2.getFilter())) {
    return false;
  }

  EnumSet<Context> cset1 = EnumSet.copyOf(c1.getContexts());
  EnumSet<Context> cset2 = EnumSet.copyOf(c2.getContexts());

  return cset1.equals(cset2);
}
 
Example 8
Source File: CloudAnalyticsClient.java    From azure-storage-android with Apache License 2.0 5 votes vote down vote up
/**
 * Returns an enumerable collection of log blobs, retrieved lazily.
 * 
 * @param service
 *            A {@link StorageService} enumeration value that indicates which storage service to use.
 * @param startTime
 *            A <code>java.util.Date</code> object representing the start of the time range for which logs should
 *            be retrieved.
 * @param endTime
 *            A <code>java.util.Date</code> object representing the end of the time range for which logs should
 *            be retrieved.
 * @param operations
 *            A {@link LoggingOperations} enumeration set that indicates which log types to return.
 * @param details
 *            A {@link BlobListingDetails} enumeration set that indicates whether or not blob metadata should
 *            be returned. None or METADATA are the only valid values.
 * @param options
 *            A {@link BlobRequestOptions} object that specifies additional options for the request.
 * @param operationContext
 *            An {@link OperationContext} object that represents the context for the current operation.
 * @return
 *         An enumerable collection of objects that implement {@link ListBlobItem} and are retrieved lazily.
 * @throws StorageException
 * @throws URISyntaxException
 */
public Iterable<ListBlobItem> listLogBlobs(StorageService service, Date startTime, Date endTime,
        EnumSet<LoggingOperations> operations, BlobListingDetails details, BlobRequestOptions options,
        OperationContext operationContext) throws StorageException, URISyntaxException {
    Utility.assertNotNull("service", service);
    if (operations == null) {
        operations = EnumSet.allOf(LoggingOperations.class);
    }

    if (!(details == null || details.equals(BlobListingDetails.METADATA))) {
        throw new IllegalArgumentException(SR.INVALID_LISTING_DETAILS);
    }

    if (operations.equals(EnumSet.noneOf(LoggingOperations.class))) {
        throw new IllegalArgumentException(SR.INVALID_LOGGING_LEVEL);
    }

    EnumSet<BlobListingDetails> metadataDetails;
    if (details != null
            && (details.equals(BlobListingDetails.METADATA) || !operations.equals(EnumSet
                    .allOf(LoggingOperations.class)))) {
        metadataDetails = EnumSet.of(BlobListingDetails.METADATA);
    }
    else {
        metadataDetails = EnumSet.noneOf(BlobListingDetails.class);
    }

    return new LogBlobIterable(this.getLogDirectory(service), startTime, endTime, operations, metadataDetails,
            options, operationContext);
}
 
Example 9
Source File: ProtoAccountDataSerializerTest.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
private boolean compareCapability(Capability c1, Capability c2) {
  if (c1.getEventType() != c2.getEventType() ||
      !c1.getFilter().equals(c2.getFilter())) {
    return false;
  }

  EnumSet<Context> cset1 = EnumSet.copyOf(c1.getContexts());
  EnumSet<Context> cset2 = EnumSet.copyOf(c2.getContexts());

  return cset1.equals(cset2);
}
 
Example 10
Source File: ThriftBackfill.java    From attic-aurora with Apache License 2.0 5 votes vote down vote up
/**
 * Ensures ResourceAggregate.resources and correspondent deprecated fields are all populated.
 *
 * @param aggregate ResourceAggregate to backfill.
 * @return Backfilled IResourceAggregate.
 */
public static IResourceAggregate backfillResourceAggregate(ResourceAggregate aggregate) {
  EnumSet<ResourceType> quotaResources = QuotaManager.QUOTA_RESOURCE_TYPES;
  if (aggregate.getResources().size() > quotaResources.size()) {
    throw new IllegalArgumentException("Too many resource values in quota.");
  }

  if (!quotaResources.equals(aggregate.getResources().stream()
      .map(e -> ResourceType.fromResource(IResource.build(e)))
      .collect(Collectors.toSet()))) {

    throw new IllegalArgumentException("Quota resources must be exactly: " + quotaResources);
  }
  return IResourceAggregate.build(aggregate);
}