當前位置: 首頁>>代碼示例>>Java>>正文


Java EnumSet.size方法代碼示例

本文整理匯總了Java中java.util.EnumSet.size方法的典型用法代碼示例。如果您正苦於以下問題:Java EnumSet.size方法的具體用法?Java EnumSet.size怎麽用?Java EnumSet.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.EnumSet的用法示例。


在下文中一共展示了EnumSet.size方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: clearBrowsingData

import java.util.EnumSet; //導入方法依賴的package包/類
/**
 * Requests the browsing data corresponding to the given dialog options to be deleted.
 * @param options The dialog options whose corresponding data should be deleted.
 */
private final void clearBrowsingData(EnumSet<DialogOption> options,
        @Nullable String[] blacklistedDomains, @Nullable int[] blacklistedDomainReasons,
        @Nullable String[] ignoredDomains, @Nullable int[] ignoredDomainReasons) {
    showProgressDialog();

    int[] dataTypes = new int[options.size()];
    int i = 0;
    for (DialogOption option : options) {
        dataTypes[i] = option.getDataType();
        ++i;
    }

    Object spinnerSelection =
            ((SpinnerPreference) findPreference(PREF_TIME_RANGE)).getSelectedOption();
    int timePeriod = ((TimePeriodSpinnerOption) spinnerSelection).getTimePeriod();
    if (blacklistedDomains != null && blacklistedDomains.length != 0) {
        PrefServiceBridge.getInstance().clearBrowsingDataExcludingDomains(this, dataTypes,
                timePeriod, blacklistedDomains, blacklistedDomainReasons, ignoredDomains,
                ignoredDomainReasons);
    } else {
        PrefServiceBridge.getInstance().clearBrowsingData(this, dataTypes, timePeriod);
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:28,代碼來源:ClearBrowsingDataPreferences.java

示例2: asImmutable

import java.util.EnumSet; //導入方法依賴的package包/類
static <E extends Enum<E>> ImmutableSet<E> asImmutable(EnumSet<E> set) {
  switch (set.size()) {
    case 0:
      return ImmutableSet.of();
    case 1:
      return ImmutableSet.of(Iterables.getOnlyElement(set));
    default:
      return new ImmutableEnumSet<E>(set);
  }
}
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:11,代碼來源:ImmutableEnumSet.java

示例3: set

import java.util.EnumSet; //導入方法依賴的package包/類
/**
 * reset the EnumSetWritable with specified
 * <tt>value</value> and <tt>elementType</tt>. If the <tt>value</tt> argument
 * is null or its size is zero, the <tt>elementType</tt> argument must not be
 * null. If the argument <tt>value</tt>'s size is bigger than zero, the
 * argument <tt>elementType</tt> is not be used.
 * 
 * @param value
 * @param elementType
 */
public void set(EnumSet<E> value, Class<E> elementType) {
  if ((value == null || value.size() == 0)
      && (this.elementType == null && elementType == null)) {
    throw new IllegalArgumentException(
        "The EnumSet argument is null, or is an empty set but with no elementType provided.");
  }
  this.value = value;
  if (value != null && value.size() > 0) {
    Iterator<E> iterator = value.iterator();
    this.elementType = iterator.next().getDeclaringClass();
  } else if (elementType != null) {
    this.elementType = elementType;
  }
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:25,代碼來源:EnumSetWritable.java

示例4: asImmutable

import java.util.EnumSet; //導入方法依賴的package包/類
@SuppressWarnings("rawtypes") // necessary to compile against Java 8
static ImmutableSet asImmutable(EnumSet set) {
  switch (set.size()) {
    case 0:
      return ImmutableSet.of();
    case 1:
      return ImmutableSet.of(Iterables.getOnlyElement(set));
    default:
      return new ImmutableEnumSet(set);
  }
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:12,代碼來源:ImmutableEnumSet.java

示例5: getEnumValuesArray

import java.util.EnumSet; //導入方法依賴的package包/類
public static ArrayList<String> getEnumValuesArray(Class<? extends Enum> enumType) {
    final EnumSet<? extends Enum> enumSet = EnumSet.allOf(enumType);
    final ArrayList<String> enumNames = new ArrayList<>(enumSet.size());
    for (Enum enumValue : enumSet) {
        enumNames.add(enumValue.name());
    }

    return enumNames;
}
 
開發者ID:ABTSoftware,項目名稱:SciChart.Android.Examples,代碼行數:10,代碼來源:EnumUtils.java

示例6: extractStringMap

import java.util.EnumSet; //導入方法依賴的package包/類
private static <T extends Enum<T>> Map<String, T> extractStringMap(final Class<T> type) {
    checkType(type);
    final EnumSet<T> values = EnumSet.allOf(type);
    final Map<String, T> strings = new HashMap<String, T>(values.size());
    for (final T value : values) {
        if (strings.put(value.toString(), value) != null) {
            throw new IllegalArgumentException("Enum type "
                + type.getName()
                + " does not have unique string representations for its values");
        }
    }
    return strings;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:14,代碼來源:EnumToStringConverter.java

示例7: findChangedFields

import java.util.EnumSet; //導入方法依賴的package包/類
protected EnumSet<DeviceField> findChangedFields(Device device,
		Entity newEntity) {
	EnumSet<DeviceField> changedFields =
			EnumSet.of(DeviceField.IPV4,
					DeviceField.VLAN,
					DeviceField.SWITCH);

	if (newEntity.getIpv4Address() == null)
		changedFields.remove(DeviceField.IPV4);
	if (newEntity.getVlan() == null)
		changedFields.remove(DeviceField.VLAN);
	if (newEntity.getSwitchDPID() == null ||
			newEntity.getSwitchPort() == null)
		changedFields.remove(DeviceField.SWITCH);

	if (changedFields.size() == 0) return changedFields;

	for (Entity entity : device.getEntities()) {
		if (newEntity.getIpv4Address() == null ||
				(entity.getIpv4Address() != null &&
				entity.getIpv4Address().equals(newEntity.getIpv4Address())))
			changedFields.remove(DeviceField.IPV4);
		if (newEntity.getVlan() == null ||
				(entity.getVlan() != null &&
				entity.getVlan().equals(newEntity.getVlan())))
			changedFields.remove(DeviceField.VLAN);
		if (newEntity.getSwitchDPID() == null ||
				newEntity.getSwitchPort() == null ||
				(entity.getSwitchDPID() != null &&
				entity.getSwitchPort() != null &&
				entity.getSwitchDPID().equals(newEntity.getSwitchDPID()) &&
				entity.getSwitchPort().equals(newEntity.getSwitchPort())))
			changedFields.remove(DeviceField.SWITCH);
	}

	return changedFields;
}
 
開發者ID:nsg-ethz,項目名稱:iTAP-controller,代碼行數:38,代碼來源:DeviceManagerImpl.java

示例8: FileInformation

import java.util.EnumSet; //導入方法依賴的package包/類
public FileInformation (GitStatus status) {
    directory = status.isFolder();
    seenInUI = true;
    renamed = status.isRenamed();
    copied = status.isCopied();
    oldFile = status.getOldPath();
    if (!status.isTracked()) {
        this.status = GitStatus.Status.STATUS_IGNORED.equals(status.getStatusIndexWC()) ? EnumSet.of(Status.NOTVERSIONED_EXCLUDED)
                : EnumSet.of(Status.NEW_INDEX_WORKING_TREE, Status.NEW_HEAD_WORKING_TREE);
    } else if (status.isConflict()) {
        this.status = EnumSet.of(Status.IN_CONFLICT);
        this.conflictType = status.getConflictDescriptor().getType();
    } else {
        GitStatus.Status statusHeadIndex = status.getStatusHeadIndex();
        GitStatus.Status statusIndexWC = status.getStatusIndexWC();
        GitStatus.Status statusHeadWC = status.getStatusHeadWC();
        EnumSet<Status> s = EnumSet.noneOf(Status.class);
        if (GitStatus.Status.STATUS_ADDED.equals(statusHeadIndex)) {
            s.add(Status.NEW_HEAD_INDEX);
        } else if (GitStatus.Status.STATUS_MODIFIED.equals(statusHeadIndex)) {
            s.add(Status.MODIFIED_HEAD_INDEX);
        } else if (GitStatus.Status.STATUS_REMOVED.equals(statusHeadIndex)) {
            s.add(Status.REMOVED_HEAD_INDEX);
        }
        if (GitStatus.Status.STATUS_ADDED.equals(statusIndexWC)) {
            s.add(Status.NEW_INDEX_WORKING_TREE);
        } else if (GitStatus.Status.STATUS_MODIFIED.equals(statusIndexWC)) {
            s.add(Status.MODIFIED_INDEX_WORKING_TREE);
        } else if (GitStatus.Status.STATUS_REMOVED.equals(statusIndexWC)) {
            s.add(Status.REMOVED_INDEX_WORKING_TREE);
        }
        if (GitStatus.Status.STATUS_MODIFIED.equals(statusHeadWC)) {
            s.add(Status.MODIFIED_HEAD_WORKING_TREE);
        } else if (GitStatus.Status.STATUS_ADDED.equals(statusHeadWC)) {
            s.add(Status.NEW_HEAD_WORKING_TREE);
        } else if (GitStatus.Status.STATUS_REMOVED.equals(statusHeadWC)) {
            s.add(Status.REMOVED_HEAD_WORKING_TREE);
        }
        // correction
        if (s.size() == 1) {
            if (s.contains(Status.MODIFIED_INDEX_WORKING_TREE) || s.contains(Status.MODIFIED_HEAD_INDEX)) {
                // does not make sense, file is modified between index and wt (or head and index) but otherwise up to date
                // let's assume it's modified also between head and wt
                Git.STATUS_LOG.log(Level.WARNING, "inconsistent status found for {0}: {1}", new Object[] { status.getFile(), s }); //NOI18N
                s.add(Status.MODIFIED_HEAD_WORKING_TREE);
            } else if (s.contains(Status.REMOVED_INDEX_WORKING_TREE) || s.contains(Status.REMOVED_HEAD_INDEX)) {
                // does not make sense, file is removed between index and wt (or head and index) but otherwise up to date
                // let's assume it's removed also between head and wt
                Git.STATUS_LOG.log(Level.WARNING, "inconsistent status found for {0}: {1}", new Object[] { status.getFile(), s }); //NOI18N
                s.add(Status.REMOVED_HEAD_WORKING_TREE);
            }
        }
        // file is removed in the WT, but is NOT in HEAD yet
        // or is removed both in WT and index
        if (GitStatus.Status.STATUS_REMOVED.equals(statusIndexWC) && !GitStatus.Status.STATUS_ADDED.equals(statusHeadIndex)
                || GitStatus.Status.STATUS_REMOVED.equals(statusHeadIndex) && GitStatus.Status.STATUS_NORMAL.equals(statusIndexWC)) {
            s.add(Status.REMOVED_HEAD_WORKING_TREE);
        }
        if (s.isEmpty()) {
            s.add(Status.UPTODATE);
        }
        this.status = s;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:65,代碼來源:FileInformation.java


注:本文中的java.util.EnumSet.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。