java.util.EnumSet.copyOf()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.0k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中java.util.EnumSet.copyOf()方法的一些代码示例,展示了EnumSet.copyOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。EnumSet.copyOf()方法的具体详情如下:
包路径:java.util.EnumSet
类名称:EnumSet
方法名:copyOf

EnumSet.copyOf介绍

[英]Creates an enum set. The contained elements are the same as those contained in collection c. If c is an enum set, invoking this method is the same as invoking #copyOf(EnumSet).
[中]创建枚举集。包含的元素与集合c中包含的元素相同。如果c是枚举集,则调用此方法与调用#copyOf(EnumSet)相同。

代码示例

代码示例来源:origin: spring-projects/spring-framework

public HttpMethodPredicate(HttpMethod... httpMethods) {
  Assert.notEmpty(httpMethods, "HttpMethods must not be empty");
  this.httpMethods = EnumSet.copyOf(Arrays.asList(httpMethods));
}

代码示例来源:origin: apache/incubator-druid

public SegmentMetadataQueryBuilder analysisTypes(SegmentMetadataQuery.AnalysisType... analysisTypes)
{
 if (analysisTypes == null) {
  this.analysisTypes = null;
 } else {
  this.analysisTypes = analysisTypes.length == 0
             ? EnumSet.noneOf(SegmentMetadataQuery.AnalysisType.class)
             : EnumSet.copyOf(Arrays.asList(analysisTypes));
 }
 return this;
}

代码示例来源:origin: google/guava

@Override
 public Set<AnEnum> create(AnEnum[] elements) {
  return (elements.length == 0)
    ? EnumSet.noneOf(AnEnum.class)
    : EnumSet.copyOf(MinimalCollection.of(elements));
 }
})

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * Create a UnicodeUnescaper.
 *
 * The constructor takes a list of options, only one type of which is currently
 * available (whether to allow, error or ignore the semi-colon on the end of a
 * numeric entity to being missing).
 *
 * For example, to support numeric entities without a ';':
 *    new NumericEntityUnescaper(NumericEntityUnescaper.OPTION.semiColonOptional)
 * and to throw an IllegalArgumentException when they're missing:
 *    new NumericEntityUnescaper(NumericEntityUnescaper.OPTION.errorIfNoSemiColon)
 *
 * Note that the default behaviour is to ignore them.
 *
 * @param options to apply to this unescaper
 */
public NumericEntityUnescaper(final OPTION... options) {
  if(options.length > 0) {
    this.options = EnumSet.copyOf(Arrays.asList(options));
  } else {
    this.options = EnumSet.copyOf(Arrays.asList(new OPTION[] { OPTION.semiColonRequired }));
  }
}

代码示例来源:origin: ethereum/ethereumj

private OpCode(int op, int require, int ret, Tier tier, CallFlags ... callFlags) {
  this.opcode = (byte) op;
  this.require = require;
  this.tier = tier;
  this.ret = ret;
  this.callFlags = callFlags.length == 0 ? EnumSet.noneOf(CallFlags.class) :
      EnumSet.copyOf(Arrays.asList(callFlags));
}

代码示例来源:origin: JZ-Darkal/AndroidHttpCapture

@Override
public void setHarCaptureTypes(Set<CaptureType> harCaptureSettings) {
  if (harCaptureSettings == null || harCaptureSettings.isEmpty()) {
    harCaptureTypes = EnumSet.noneOf(CaptureType.class);
  } else {
    harCaptureTypes = EnumSet.copyOf(harCaptureSettings);
  }
}

代码示例来源:origin: requery/requery

public AttributeBuilder<T, V> setCascadeAction(CascadeAction ...actions) {
  this.cascadeActions = EnumSet.copyOf(Arrays.asList(actions));
  return this;
}

代码示例来源:origin: mabe02/lanterna

private static EnumSet<SGR> toEnumSet(SGR... modifiers) {
  if(modifiers.length == 0) {
    return EnumSet.noneOf(SGR.class);
  }
  else {
    return EnumSet.copyOf(Arrays.asList(modifiers));
  }
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Return the set of allowed {@link HttpMethod HTTP methods},
 * as specified by the {@code Allow} header.
 * <p>Returns an empty set when the allowed methods are unspecified.
 */
public Set<HttpMethod> getAllow() {
  String value = getFirst(ALLOW);
  if (!StringUtils.isEmpty(value)) {
    String[] tokens = StringUtils.tokenizeToStringArray(value, ",");
    List<HttpMethod> result = new ArrayList<>(tokens.length);
    for (String token : tokens) {
      HttpMethod resolved = HttpMethod.resolve(token);
      if (resolved != null) {
        result.add(resolved);
      }
    }
    return EnumSet.copyOf(result);
  }
  else {
    return EnumSet.noneOf(HttpMethod.class);
  }
}

代码示例来源:origin: Bukkit/Bukkit

public Vine(BlockFace... faces) {
  this(EnumSet.copyOf(Arrays.asList(faces)));
}

代码示例来源:origin: apache/ignite

/** {@inheritDoc} */
@Override public GridClientData flagsOn(GridClientCacheFlag... flags) throws GridClientException {
  if (flags == null || flags.length == 0)
    return this;
  EnumSet<GridClientCacheFlag> flagSet = this.flags == null || this.flags.isEmpty() ?
    EnumSet.noneOf(GridClientCacheFlag.class) : EnumSet.copyOf(this.flags);
  flagSet.addAll(Arrays.asList(flags));
  return createProjection(nodes, filter, balancer, new GridClientDataFactory(flagSet));
}

代码示例来源:origin: mabe02/lanterna

@Override
  public EnumSet<SGR> getSGRs() {
    ThemeTreeNode node = styleNode;
    while(node != null) {
      if(node.sgrMap.containsKey(name)) {
        return EnumSet.copyOf(node.sgrMap.get(name));
      }
      node = node.parent;
    }
    EnumSet<SGR> fallback = rootNode.sgrMap.get(STYLE_NORMAL);
    if(fallback == null) {
      fallback = EnumSet.noneOf(SGR.class);
    }
    return EnumSet.copyOf(fallback);
  }
}

代码示例来源:origin: SonarSource/sonarqube

private static Set<State> toSet(State... states) {
 if (states.length == 0) {
  return Collections.emptySet();
 }
 if (states.length == 1) {
  return Collections.singleton(states[0]);
 }
 return EnumSet.copyOf(Arrays.asList(states));
}

代码示例来源:origin: JZ-Darkal/AndroidHttpCapture

@Override
public void disableHarCaptureTypes(CaptureType... captureTypes) {
  if (captureTypes == null) {
    disableHarCaptureTypes(EnumSet.noneOf(CaptureType.class));
  } else {
    disableHarCaptureTypes(EnumSet.copyOf(Arrays.asList(captureTypes)));
  }
}

代码示例来源:origin: line/armeria

/**
 * Returns all annotations searching from the specified {@code element}. The search range depends on
 * the specified {@link FindOption}s and the built-in Java meta-annotations will not be collected.
 *
 * @param element the {@link AnnotatedElement} to find annotations
 * @param findOptions the options to be applied when retrieving annotations
 */
static List<Annotation> getAnnotations(AnnotatedElement element, FindOption... findOptions) {
  requireNonNull(findOptions, "findOptions");
  return getAnnotations(element,
             findOptions.length > 0 ? EnumSet.copyOf(ImmutableList.copyOf(findOptions))
                         : EnumSet.noneOf(FindOption.class));
}

代码示例来源:origin: SonarSource/sonarqube

private static Set<State> toSet(State... states) {
 if (states.length == 0) {
  return Collections.emptySet();
 }
 if (states.length == 1) {
  return Collections.singleton(states[0]);
 }
 return EnumSet.copyOf(Arrays.asList(states));
}

代码示例来源:origin: JZ-Darkal/AndroidHttpCapture

@Override
public void enableHarCaptureTypes(CaptureType... captureTypes) {
  if (captureTypes == null) {
    enableHarCaptureTypes(EnumSet.noneOf(CaptureType.class));
  } else {
    enableHarCaptureTypes(EnumSet.copyOf(Arrays.asList(captureTypes)));
  }
}

代码示例来源:origin: aragozin/jvm-tools

ThreadStateMatcher(String pattern) {
  Pattern regEx = Pattern.compile(wildCardTranslate(pattern));
  Set<State> st = new HashSet<State>();
  for(State s: State.values()) {
    if (regEx.matcher(s.toString()).matches()) {
      st.add(s);
    }
  }
  states = st.isEmpty() ? EnumSet.noneOf(State.class) : EnumSet.copyOf(st);
  matchNull = regEx.matcher(String.valueOf((Object)null)).matches();
}

代码示例来源:origin: SonarSource/sonarqube

private static Set<State> toSet(State... states) {
 if (states.length == 0) {
  return Collections.emptySet();
 }
 if (states.length == 1) {
  return Collections.singleton(states[0]);
 }
 return EnumSet.copyOf(Arrays.asList(states));
}

代码示例来源:origin: JZ-Darkal/AndroidHttpCapture

@Override
public void setHarCaptureTypes(CaptureType... captureTypes) {
  if (captureTypes == null) {
    setHarCaptureTypes(EnumSet.noneOf(CaptureType.class));
  } else {
    setHarCaptureTypes(EnumSet.copyOf(Arrays.asList(captureTypes)));
  }
}

相关文章