当前位置: 首页>>代码示例>>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;未经允许,请勿转载。