Java Code Examples for java.util.EnumSet

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project FML, under directory /common/cpw/mods/fml/common/modloader/.

Source file: BaseModTicker.java

  18 
vote

private void tickBaseMod(EnumSet<TickType> types,boolean end,Object... tickData){
  if (FMLCommonHandler.instance().getSide().isClient() && (ticks.contains(TickType.CLIENT) || ticks.contains(TickType.WORLDLOAD))) {
    EnumSet cTypes=EnumSet.copyOf(types);
    if ((end && types.contains(TickType.CLIENT)) || types.contains(TickType.WORLDLOAD)) {
      clockTickTrigger=true;
      cTypes.remove(TickType.CLIENT);
      cTypes.remove(TickType.WORLDLOAD);
    }
    if (end && clockTickTrigger && types.contains(TickType.RENDER)) {
      clockTickTrigger=false;
      cTypes.remove(TickType.RENDER);
      cTypes.add(TickType.CLIENT);
    }
    sendTick(cTypes,end,tickData);
  }
 else {
    sendTick(types,end,tickData);
  }
}
 

Example 2

From project adbcj, under directory /mysql/codec/src/main/java/org/adbcj/mysql/codec/.

Source file: IoUtils.java

  15 
vote

private static <E extends Enum<E>>EnumSet<E> toEnumSet(Class<E> enumClass,long vector){
  EnumSet<E> set=EnumSet.noneOf(enumClass);
  long mask=1;
  for (  E e : enumClass.getEnumConstants()) {
    if ((mask & vector) == mask) {
      set.add(e);
    }
    mask<<=1;
  }
  return set;
}
 

Example 3

From project agileBase, under directory /gtpb_server/src/com/gtwm/pb/model/manageData/.

Source file: ViewTools.java

  15 
vote

public Set<FieldTypeDescriptorInfo> getFieldTypeDescriptors() throws ObjectNotFoundException {
  Set<FieldTypeDescriptorInfo> fieldTypeDescriptors=new LinkedHashSet<FieldTypeDescriptorInfo>();
  for (  FieldCategory possibleFieldType : EnumSet.allOf(FieldTypeDescriptor.FieldCategory.class)) {
    if (possibleFieldType.isEnabled()) {
      FieldTypeDescriptorInfo fieldTypeDescriptor=new FieldTypeDescriptor(possibleFieldType);
      fieldTypeDescriptors.add(fieldTypeDescriptor);
    }
  }
  return fieldTypeDescriptors;
}
 

Example 4

From project agraph-java-client, under directory /src/com/franz/agraph/pool/.

Source file: AGConnPool.java

  15 
vote

protected static Map<? extends Enum,String> toMap(Object[] keyValuePairs,EnumSet<? extends Enum> enumSet){
  Map<Enum,String> map=new HashMap<Enum,String>();
  for (int i=0; i < keyValuePairs.length; i=i + 2) {
    Enum key=(Enum)keyValuePairs[i];
    if (enumSet.contains(key)) {
      Object val=keyValuePairs[i + 1];
      map.put(key,val == null ? null : val.toString());
    }
  }
  return map;
}
 

Example 5

From project Airports, under directory /src/com/nadmm/airports/wx/.

Source file: Metar.java

  15 
vote

public Metar(){
  isValid=false;
  observationTime=0;
  fetchTime=0;
  tempCelsius=Float.MAX_VALUE;
  dewpointCelsius=Float.MAX_VALUE;
  windDirDegrees=Integer.MAX_VALUE;
  windSpeedKnots=Integer.MAX_VALUE;
  windGustKnots=Integer.MAX_VALUE;
  windPeakKnots=Integer.MAX_VALUE;
  visibilitySM=Float.MAX_VALUE;
  altimeterHg=Float.MAX_VALUE;
  seaLevelPressureMb=Float.MAX_VALUE;
  pressureTend3HrMb=Float.MAX_VALUE;
  maxTemp6HrCentigrade=Float.MAX_VALUE;
  minTemp6HrCentigrade=Float.MAX_VALUE;
  maxTemp24HrCentigrade=Float.MAX_VALUE;
  minTemp24HrCentigrade=Float.MAX_VALUE;
  precipInches=Float.MAX_VALUE;
  precip3HrInches=Float.MAX_VALUE;
  precip6HrInches=Float.MAX_VALUE;
  precip24HrInches=Float.MAX_VALUE;
  snowInches=Float.MAX_VALUE;
  vertVisibilityFeet=Integer.MAX_VALUE;
  stationElevationMeters=Float.MAX_VALUE;
  wxList=new ArrayList<WxSymbol>();
  skyConditions=new ArrayList<SkyCondition>();
  flags=EnumSet.noneOf(Flags.class);
  presrr=false;
  presfr=false;
  snincr=false;
  wshft=false;
  fropa=false;
}
 

Example 6

From project ajah, under directory /ajah-spring-mvc/src/main/java/com/ajah/spring/mvc/util/.

Source file: FilterUtils.java

  15 
vote

/** 
 * Convenience method for adding a filter that is available as a Spring bean/service to all requests.
 * @see ServletContext#addFilter(String,Class)
 * @param filterClass The class of Filter to instantiate.
 * @param appContext The application context to find the bean in.
 * @param servletContext
 * @return The Dynamic Mapping created by this method.
 */
public static Dynamic add(final Class<? extends Filter> filterClass,final ApplicationContext appContext,final ServletContext servletContext){
  final Filter filter=appContext.getBean(filterClass);
  final FilterRegistration.Dynamic reg=servletContext.addFilter(filterClass.getName(),filter);
  reg.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST),true,"/*");
  return reg;
}
 

Example 7

From project and-bible, under directory /AndBackendTest/src/net/bible/service/sword/.

Source file: SwordApiTest.java

  15 
vote

public void testCheckISVVersesExist(){
  Book isv=Books.installed().getBook("ISV");
  for (  BibleBook book : EnumSet.range(BibleBook.GEN,BibleBook.REV)) {
    System.out.println(book);
    try {
      for (int chap=1; chap <= BibleInfo.chaptersInBook(book); chap++) {
        for (int verse=1; verse <= BibleInfo.versesInChapter(book,chap); verse++) {
          Key key=isv.getKey(new Verse(book,chap,verse).getOsisID());
          BookData data=new BookData(isv,key);
          String plainText=OSISUtil.getCanonicalText(data.getOsisFragment());
          if (plainText.isEmpty()) {
            System.out.println("Missing:" + key.getOsisID());
          }
        }
      }
    }
 catch (    Exception e) {
      System.out.println("missing verse");
    }
  }
}
 

Example 8

From project android-viewflow, under directory /viewflow/src/org/taptwo/android/widget/.

Source file: ViewFlow.java

  15 
vote

private void resetFocus(){
  logBuffer();
  recycleViews();
  removeAllViewsInLayout();
  mLazyInit.addAll(EnumSet.allOf(LazyInit.class));
  for (int i=Math.max(0,mCurrentAdapterIndex - mSideBuffer); i < Math.min(mAdapter.getCount(),mCurrentAdapterIndex + mSideBuffer + 1); i++) {
    mLoadedViews.addLast(makeAndAddView(i,true));
    if (i == mCurrentAdapterIndex) {
      mCurrentBufferIndex=mLoadedViews.size() - 1;
      if (mViewInitializeListener != null)       mViewInitializeListener.onViewLazyInitialize(mLoadedViews.getLast(),mCurrentAdapterIndex);
    }
  }
  logBuffer();
  requestLayout();
}
 

Example 9

From project android_external_guava, under directory /src/com/google/common/collect/.

Source file: Sets.java

  15 
vote

/** 
 * Returns an immutable set instance containing the given enum elements. Internally, the returned set will be backed by an  {@link EnumSet}. <p>The iteration order of the returned set follows the enum's iteration order, not the order in which the elements appear in the given collection.
 * @param elements the elements, all of the same {@code enum} type, that theset should contain
 * @return an immutable set containing those elements, minus duplicates
 */
@GwtCompatible(serializable=true) public static <E extends Enum<E>>ImmutableSet<E> immutableEnumSet(Iterable<E> elements){
  Iterator<E> iterator=elements.iterator();
  if (!iterator.hasNext()) {
    return ImmutableSet.of();
  }
  if (elements instanceof EnumSet) {
    EnumSet<E> enumSetClone=EnumSet.copyOf((EnumSet<E>)elements);
    return new ImmutableEnumSet<E>(enumSetClone);
  }
  E first=iterator.next();
  EnumSet<E> set=EnumSet.of(first);
  while (iterator.hasNext()) {
    set.add(iterator.next());
  }
  return new ImmutableEnumSet<E>(set);
}
 

Example 10

From project android_external_libphonenumber, under directory /java/test/com/android/i18n/phonenumbers/.

Source file: ExampleNumbersTest.java

  15 
vote

public void testFixedLine() throws Exception {
  Set<PhoneNumberType> fixedLineTypes=EnumSet.of(PhoneNumberType.FIXED_LINE,PhoneNumberType.FIXED_LINE_OR_MOBILE);
  checkNumbersValidAndCorrectType(PhoneNumberType.FIXED_LINE,fixedLineTypes);
  assertEquals(0,invalidCases.size());
  assertEquals(0,wrongTypeCases.size());
}
 

Example 11

From project apb, under directory /modules/apb-base/src/apb/.

Source file: ApbOptions.java

  15 
vote

EnumSet<DebugOption> debugOptions(){
  EnumSet<DebugOption> result=EnumSet.noneOf(DebugOption.class);
  for (  String d : debug.getValues()) {
    if (d.equals(DebugOption.ALL)) {
      return EnumSet.allOf(DebugOption.class);
    }
    DebugOption o=DebugOption.find(d);
    if (o != null) {
      result.add(o);
    }
  }
  if (track.getValue()) {
    result.add(DebugOption.TRACK);
  }
  if (verbose.getValue()) {
    result.add(DebugOption.TASK_INFO);
  }
  return result;
}
 

Example 12

From project ardverk-commons, under directory /src/main/java/org/ardverk/lang/.

Source file: EnumUtils.java

  15 
vote

/** 
 * Creates and returns an  {@link EnumSet}
 */
@SafeVarargs public static <E extends Enum<E>>EnumSet<E> createSet(Class<E> clazz,E... elements){
switch (elements.length) {
case 0:
    return EnumSet.noneOf(clazz);
case 1:
  return EnumSet.of(elements[0]);
case 2:
return EnumSet.of(elements[0],elements[1]);
case 3:
return EnumSet.of(elements[0],elements[1],elements[2]);
case 4:
return EnumSet.of(elements[0],elements[1],elements[2],elements[3]);
default :
E first=elements[0];
E[] others=ArrayUtils.newInstance(clazz,elements.length - 1);
System.arraycopy(elements,1,others,0,others.length);
return EnumSet.of(first,others);
}
}
 

Example 13

From project Arecibo, under directory /util/src/main/java/com/ning/arecibo/util/.

Source file: EmbeddedJettyJerseyProvider.java

  15 
vote

@Override public Server get(){
  QueuedThreadPool threadPool=new QueuedThreadPool();
  threadPool.setMinThreads(config.getMinThreads());
  threadPool.setMaxThreads(config.getMaxThreads());
  SelectChannelConnector connector=new SelectChannelConnector();
  connector.setHost(config.getHost());
  connector.setPort(config.getPort());
  connector.setMaxIdleTime(30000);
  connector.setAcceptors(2);
  connector.setStatsOn(true);
  connector.setLowResourcesConnections(20000);
  connector.setLowResourceMaxIdleTime(5000);
  connector.setAcceptQueueSize(config.getAcceptQueueSize());
  Server server=new Server(config.getPort());
  server.setThreadPool(threadPool);
  server.setConnectors(new Connector[]{connector});
  server.setGracefulShutdown(1000);
  ServletContextHandler root=new ServletContextHandler(server,"/",ServletContextHandler.SESSIONS);
  root.setResourceBase(config.getResourceBase());
  final FilterHolder filterHolder=new FilterHolder(GuiceFilter.class);
  root.addFilter(filterHolder,"/*",EnumSet.of(DispatcherType.REQUEST,DispatcherType.ASYNC));
  final ServletHolder sh=new ServletHolder(DefaultServlet.class);
  root.addServlet(sh,"/*");
  root.addEventListener(new GuiceServletContextListener(){
    @Override protected Injector getInjector(){
      return injector;
    }
  }
);
  root.addServlet(DefaultServlet.class,"/");
  return server;
}
 

Example 14

From project arquillian-extension-android, under directory /android-impl/src/main/java/org/jboss/arquillian/android/impl/.

Source file: CountDownWatch.java

  15 
vote

/** 
 * Creates a countdown watch and starts it
 * @param timeout timeout
 * @param unit timeout unit
 */
public CountDownWatch(long timeout,TimeUnit unit){
  if (EnumSet.of(TimeUnit.MICROSECONDS,TimeUnit.MILLISECONDS).contains(unit)) {
    throw new IllegalArgumentException(MessageFormat.format("Time Unit {0} is not supported",unit));
  }
  this.timeStart=System.currentTimeMillis();
  this.timeout=timeout;
  this.unit=unit;
}
 

Example 15

From project avro, under directory /lang/java/ipc/src/main/java/org/apache/avro/ipc/trace/.

Source file: Util.java

  15 
vote

/** 
 * Get all SpanEvents contained in Span s.
 */
public static EnumSet<SpanEvent> getAllEvents(Span s){
  EnumSet<SpanEvent> foundEvents=EnumSet.noneOf(SpanEvent.class);
  for (  TimestampedEvent event : s.events) {
    if (event.event instanceof SpanEvent) {
      foundEvents.add((SpanEvent)event.event);
    }
  }
  return foundEvents;
}
 

Example 16

From project aws-tasks, under directory /src/it/java/datameer/awstasks/aws/ec2/.

Source file: InstanceGroupImplIntegTest.java

  15 
vote

@Test public void testStartStop() throws Exception {
  AmazonEC2 ec2=_ec2Conf.createEc2();
  InstanceGroup instanceGroup=new InstanceGroupImpl(ec2);
  Reservation reservation=instanceGroup.launch(createEbsLaunchConfiguration(1),TimeUnit.MINUTES,10);
  assertTrue(instanceGroup.isAssociated());
  Volume volume=findEbsVolume(ec2);
  ec2.attachVolume(new AttachVolumeRequest(volume.getVolumeId(),reservation.getInstances().get(0).getInstanceId(),"/dev/sdb1"));
  instanceGroup.stop();
  assertFalse(instanceGroup.isAssociated());
  Ec2Util.waitUntil(ec2,reservation.getInstances(),EnumSet.of(InstanceStateName.Stopping),InstanceStateName.Stopped);
  instanceGroup.start(Ec2Util.getInstanceIds(reservation),TimeUnit.MINUTES,10);
  assertTrue(instanceGroup.isAssociated());
  instanceGroup.terminate();
  Ec2Util.waitUntil(ec2,reservation.getInstances(),EnumSet.of(InstanceStateName.ShuttingDown),InstanceStateName.Terminated);
  Thread.sleep(500);
}
 

Example 17

From project BeeQueue, under directory /src/org/beequeue/sql/mapping/.

Source file: EnumSetType.java

  15 
vote

@SuppressWarnings("unchecked") public EnumSet<T> get(ResultSet rs,Index idx) throws SQLException {
  try {
    if (values == null) {
synchronized (this) {
        if (values == null) {
          Method method=enumClass.getMethod("values",new Class[0]);
          values=(T[])method.invoke(null,new Object[0]);
        }
      }
    }
  }
 catch (  Exception e) {
    throw new SQLException(e.toString());
  }
  return buildSet(EnumSet.noneOf(enumClass),values,rs.getInt(idx.next()));
}
 

Example 18

From project brut.apktool.smali, under directory /dexlib/src/main/java/org/jf/dexlib/Code/Analysis/.

Source file: MethodAnalyzer.java

  15 
vote

private void verifyReturn(AnalyzedInstruction analyzedInstruction,EnumSet validCategories){
  SingleRegisterInstruction instruction=(SingleRegisterInstruction)analyzedInstruction.instruction;
  int returnRegister=instruction.getRegisterA();
  RegisterType returnRegisterType=getAndCheckSourceRegister(analyzedInstruction,returnRegister,validCategories);
  TypeIdItem returnType=encodedMethod.method.getPrototype().getReturnType();
  if (returnType.getTypeDescriptor().charAt(0) == 'V') {
    throw new ValidationException("Cannot use return with a void return type. Use return-void instead");
  }
  RegisterType methodReturnRegisterType=RegisterType.getRegisterTypeForTypeIdItem(returnType);
  if (!validCategories.contains(methodReturnRegisterType.category)) {
    throw new ValidationException(String.format("Cannot use %s with return type %s",analyzedInstruction.instruction.opcode.name,returnType.getTypeDescriptor()));
  }
  if (validCategories == ReferenceCategories) {
    if (methodReturnRegisterType.type.isInterface()) {
      if (returnRegisterType.category != RegisterType.Category.Null && !returnRegisterType.type.implementsInterface(methodReturnRegisterType.type)) {
      }
    }
 else {
      if (returnRegisterType.category == RegisterType.Category.Reference && !returnRegisterType.type.extendsClass(methodReturnRegisterType.type)) {
        throw new ValidationException(String.format("The return value in register v%d (%s) is not " + "compatible with the method's return type %s",returnRegister,returnRegisterType.type.getClassType(),methodReturnRegisterType.type.getClassType()));
      }
    }
  }
}
 

Example 19

From project Carolina-Digital-Repository, under directory /access-security/src/main/java/edu/unc/lib/dl/security/access/.

Source file: UserSecurityProfile.java

  15 
vote

public void put(String id,AccessType accessType){
  if (this.containsKey(id)) {
    EnumSet<AccessType> accessTypes=this.get(id);
    accessTypes.add(accessType);
  }
 else {
    EnumSet<AccessType> accessTypes=EnumSet.noneOf(AccessType.class);
    accessTypes.add(accessType);
    this.put(id,accessTypes);
  }
}
 

Example 20

From project clearcase-plugin, under directory /src/main/java/hudson/plugins/clearcase/.

Source file: ClearToolExec.java

  15 
vote

@Override public Reader diffbl(EnumSet<DiffBlOptions> type,String baseline1,String baseline2,String viewPath) throws IOException {
  ArgumentListBuilder cmd=new ArgumentListBuilder();
  cmd.add("diffbl");
  if (type != null) {
    for (    DiffBlOptions t : type) {
      cmd.add(getOption(t));
    }
  }
  cmd.add(baseline1);
  cmd.add(baseline2);
  File tmpFile=null;
  try {
    tmpFile=File.createTempFile("cleartool-diffbl",null);
  }
 catch (  IOException e) {
    throw new IOException("Couldn't create a temporary file",e);
  }
  OutputStream out=new FileOutputStream(tmpFile);
  FilePath workingDirectory=launcher.getWorkspace();
  if (viewPath != null) {
    workingDirectory=workingDirectory.child(viewPath);
  }
  try {
    launcher.run(cmd.toCommandArray(),null,out,workingDirectory,true);
  }
 catch (  IOException e) {
  }
catch (  InterruptedException e) {
  }
  out.close();
  return new InputStreamReader(new DeleteOnCloseFileInputStream(tmpFile));
}
 

Example 21

From project coffeescript-netbeans, under directory /src/coffeescript/nb/.

Source file: CoffeeScriptLanguage.java

  15 
vote

@Override protected Map<String,Collection<CoffeeScriptTokenId>> createTokenCategories(){
  Map<String,Collection<CoffeeScriptTokenId>> map=new HashMap<String,Collection<CoffeeScriptTokenId>>();
  for (  CoffeeScriptTokenId token : EnumSet.allOf(CoffeeScriptTokenId.class)) {
    Collection<CoffeeScriptTokenId> tokens=map.get(token.primaryCategory());
    if (tokens == null) {
      tokens=new HashSet<CoffeeScriptTokenId>();
      map.put(token.primaryCategory(),tokens);
    }
    tokens.add(token);
  }
  return map;
}
 

Example 22

From project commons-compress, under directory /src/main/java/org/apache/commons/compress/archivers/dump/.

Source file: DumpArchiveEntry.java

  15 
vote

public static Set<PERMISSION> find(int code){
  Set<PERMISSION> set=new HashSet<PERMISSION>();
  for (  PERMISSION p : PERMISSION.values()) {
    if ((code & p.code) == p.code) {
      set.add(p);
    }
  }
  if (set.isEmpty()) {
    return Collections.emptySet();
  }
  return EnumSet.copyOf(set);
}
 

Example 23

From project Core_2, under directory /shell-api/src/main/java/org/jboss/forge/resources/.

Source file: AbstractResource.java

  15 
vote

@Override public void setFlag(final ResourceFlag flag){
  if (flags == null) {
    flags=EnumSet.of(flag);
  }
 else {
    flags.add(flag);
  }
}
 

Example 24

From project core_4, under directory /impl/src/main/java/org/richfaces/context/.

Source file: BaseExtendedVisitContext.java

  15 
vote

/** 
 * Creates a PartialVisitorContext instance with the specified hints.
 * @param facesContext the FacesContext for the current request
 * @param clientIds the client ids of the components to visit
 * @param hints a the VisitHints for this visit
 * @throws NullPointerException if {@code facesContext} is {@code null}
 */
public BaseExtendedVisitContext(FacesContext facesContext,Collection<String> clientIds,Set<VisitHint> hints,ExtendedVisitContextMode contextMode){
  super(facesContext,contextMode);
  initializeCollections(clientIds);
  EnumSet<VisitHint> hintsEnumSet=((hints == null) || (hints.isEmpty())) ? EnumSet.noneOf(VisitHint.class) : EnumSet.copyOf(hints);
  this.hints=Collections.unmodifiableSet(hintsEnumSet);
}
 

Example 25

From project dci-examples, under directory /moneytransfer/java/ant-kutschera/OOPSOADCI_COMMON/src/ch/maxant/oopsoadci_common/bankingexample/data/.

Source file: LedgerEntry.java

  15 
vote

public static LedgerEntrySide find(char c){
  for (  LedgerEntrySide les : EnumSet.allOf(LedgerEntrySide.class)) {
    if (les.value == c) {
      return les;
    }
  }
  return null;
}
 

Example 26

From project dcm4che, under directory /dcm4che-conf/dcm4che-conf-ldap/src/main/java/org/dcm4che/conf/ldap/.

Source file: ExtendedLdapDicomConfiguration.java

  15 
vote

@Override protected Attributes storeTo(TransferCapability tc,Attributes attrs){
  super.storeTo(tc,attrs);
  EnumSet<QueryOption> queryOpts=tc.getQueryOptions();
  if (queryOpts != null) {
    storeNotDef(attrs,"dcmRelationalQueries",queryOpts.contains(QueryOption.RELATIONAL),false);
    storeNotDef(attrs,"dcmCombinedDateTimeMatching",queryOpts.contains(QueryOption.DATETIME),false);
    storeNotDef(attrs,"dcmFuzzySemanticMatching",queryOpts.contains(QueryOption.FUZZY),false);
    storeNotDef(attrs,"dcmTimezoneQueryAdjustment",queryOpts.contains(QueryOption.TIMEZONE),false);
  }
  StorageOptions storageOpts=tc.getStorageOptions();
  if (storageOpts != null) {
    storeInt(attrs,"dcmStorageConformance",storageOpts.getLevelOfSupport().ordinal());
    storeInt(attrs,"dcmDigitalSignatureSupport",storageOpts.getDigitalSignatureSupport().ordinal());
    storeInt(attrs,"dcmDataElementCoercion",storageOpts.getElementCoercion().ordinal());
  }
  return attrs;
}
 

Example 27

From project DistCpV2-0.20.203, under directory /src/main/java/org/apache/hadoop/tools/mapred/.

Source file: CopyCommitter.java

  15 
vote

private void preserveFileAttributes(Configuration conf) throws IOException {
  String attrSymbols=conf.get(DistCpConstants.CONF_LABEL_PRESERVE_STATUS);
  LOG.info("About to preserve attributes: " + attrSymbols);
  EnumSet<FileAttribute> attributes=DistCpUtils.unpackAttributes(attrSymbols);
  Path sourceListing=new Path(conf.get(DistCpConstants.CONF_LABEL_LISTING_FILE_PATH));
  FileSystem clusterFS=sourceListing.getFileSystem(conf);
  SequenceFile.Reader sourceReader=new SequenceFile.Reader(clusterFS,sourceListing,conf);
  long totalLen=clusterFS.getFileStatus(sourceListing).getLen();
  Path targetRoot=new Path(conf.get(DistCpConstants.CONF_LABEL_TARGET_WORK_PATH));
  long preservedEntries=0;
  try {
    FileStatus srcFileStatus=new FileStatus();
    Text srcRelPath=new Text();
    while (sourceReader.next(srcRelPath,srcFileStatus)) {
      if (!srcFileStatus.isDir())       continue;
      Path targetFile=new Path(targetRoot.toString() + "/" + srcRelPath);
      if (targetRoot.equals(targetFile))       continue;
      FileSystem targetFS=targetFile.getFileSystem(conf);
      DistCpUtils.preserve(targetFS,targetFile,srcFileStatus,attributes);
      taskAttemptContext.progress();
      taskAttemptContext.setStatus("Preserving status on directory entries. [" + sourceReader.getPosition() * 100 / totalLen + "%]");
    }
  }
  finally {
    IOUtils.closeStream(sourceReader);
  }
  LOG.info("Preserved status on " + preservedEntries + " dir entries on target");
}
 

Example 28

From project dragon, under directory /hadoop-dragon-core/src/main/java/org/apache/hadoop/realtime/jobhistory/.

Source file: JobHistoryEventHandler.java

  15 
vote

protected void handleEvent(JobHistoryEvent event){
synchronized (lock) {
    if (event.getHistoryEvent().getEventType() == EventType.JOB_INITED) {
      try {
        setupEventWriter(event.getJobId());
      }
 catch (      IOException ioe) {
        LOG.error("Error JobHistoryEventHandler in handleEvent: " + event,ioe);
        throw new YarnException(ioe);
      }
    }
    MetaInfo mi=fileMap.get(event.getJobId());
    try {
      HistoryEvent historyEvent=event.getHistoryEvent();
      mi.writeEvent(historyEvent);
      if (LOG.isDebugEnabled()) {
        LOG.debug("In HistoryEventHandler " + event.getHistoryEvent().getEventType());
      }
      if (EnumSet.of(EventType.JOB_UNSUCCESSFUL_COMPLETION).contains(event.getHistoryEvent().getEventType())) {
        closeEventWriter(event.getJobId());
      }
    }
 catch (    IOException e) {
      LOG.error("Error writing History Event: " + event.getHistoryEvent(),e);
      throw new YarnException(e);
    }
  }
}
 

Example 29

From project drools-planner, under directory /drools-planner-examples/src/main/java/org/drools/planner/examples/manners2009/domain/.

Source file: Manners2009.java

  15 
vote

public Collection<? extends Object> getProblemFacts(){
  List<Object> facts=new ArrayList<Object>();
  facts.addAll(EnumSet.allOf(JobType.class));
  facts.addAll(jobList);
  facts.addAll(guestList);
  facts.addAll(EnumSet.allOf(Hobby.class));
  facts.addAll(hobbyPracticianList);
  facts.addAll(tableList);
  facts.addAll(seatList);
  return facts;
}
 

Example 30

From project droolsjbpm-tools, under directory /drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/views/model/.

Source file: TreeParent.java

  15 
vote

public void fetchDeferredChildren(Object object,IElementCollector collector,IProgressMonitor monitor){
  if (!(object instanceof TreeParent)) {
    return;
  }
  TreeParent node=(TreeParent)object;
  if (node.getNodeType() == Type.NONE) {
    List<GuvnorRepository> reps=Activator.getLocationManager().getRepositories();
    monitor.beginTask(Messages.getString("pending"),reps.size());
    for (int i=0; i < reps.size(); i++) {
      TreeParent p=new TreeParent(reps.get(i).getLocation(),Type.REPOSITORY);
      p.setParent(node);
      p.setGuvnorRepository(reps.get(i));
      ResourceProperties props=new ResourceProperties();
      props.setBase("");
      p.setResourceProps(props);
      collector.add(p,monitor);
      monitor.worked(1);
    }
    monitor.done();
  }
  if (EnumSet.of(Type.REPOSITORY,Type.GLOBALS,Type.PACKAGES,Type.SNAPSHOTS,Type.PACKAGE,Type.SNAPSHOT_PACKAGE).contains(node.getNodeType())) {
    listDirectory(node,collector,monitor);
  }
}
 

Example 31

From project eik, under directory /plugins/info.evanchik.eclipse.karaf.workbench/src/main/java/info/evanchik/eclipse/karaf/workbench/internal/eclipse/.

Source file: EclipseRuntimeDataProvider.java

  15 
vote

@Override public void bundleChanged(BundleEvent event){
  final BundleItem wrappedBundle=new BundleItem(event.getBundle(),startLevel,packageAdmin);
  EnumSet<RuntimeDataProviderListener.EventType> events=EnumSet.noneOf(RuntimeDataProviderListener.EventType.class);
switch (event.getType()) {
case BundleEvent.INSTALLED:
synchronized (bundleSet) {
      if (!bundleSet.contains(wrappedBundle)) {
        bundleSet.add(wrappedBundle);
        events=EnumSet.of(RuntimeDataProviderListener.EventType.ADD);
      }
    }
  break;
case BundleEvent.UNINSTALLED:
synchronized (bundleSet) {
  if (bundleSet.contains(wrappedBundle)) {
    bundleSet.remove(wrappedBundle);
    events=EnumSet.of(RuntimeDataProviderListener.EventType.REMOVE);
  }
}
break;
default :
events=EnumSet.of(RuntimeDataProviderListener.EventType.CHANGE);
break;
}
fireProviderChangeEvent(events);
}
 

Example 32

From project encog-java-core, under directory /src/main/java/org/encog/ml/hmm/alog/.

Source file: ForwardBackwardCalculator.java

  15 
vote

/** 
 * Construct the object. 
 * @param oseq The sequence.
 * @param hmm The hidden markov model to use.
 * @param flags Flags, alpha or beta.
 */
public ForwardBackwardCalculator(final MLDataSet oseq,final HiddenMarkovModel hmm,final EnumSet<Computation> flags){
  if (oseq.size() < 1) {
    throw new IllegalArgumentException("Empty sequence");
  }
  if (flags.contains(Computation.ALPHA)) {
    computeAlpha(hmm,oseq);
  }
  if (flags.contains(Computation.BETA)) {
    computeBeta(hmm,oseq);
  }
  computeProbability(oseq,hmm,flags);
}
 

Example 33

From project floodlight, under directory /src/main/java/net/floodlightcontroller/devicemanager/internal/.

Source file: DeviceManagerImpl.java

  15 
vote

/** 
 * 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 34

From project Foglyn, under directory /com.foglyn.core/src/com/foglyn/core/.

Source file: FoglynConstants.java

  15 
vote

public static Set<Dependency> parseDependsOn(String dependsOn){
  if (dependsOn == null) {
    return Collections.emptySet();
  }
  Set<Dependency> result=EnumSet.noneOf(Dependency.class);
  String[] deps=dependsOn.split(",");
  for (  String d : deps) {
    result.add(Dependency.fromKey(d));
  }
  return result;
}
 

Example 35

From project gecko, under directory /src/main/java/com/taobao/gecko/core/buffer/.

Source file: AbstractIoBuffer.java

  15 
vote

private <E extends Enum<E>>EnumSet<E> toEnumSet(Class<E> clazz,long vector){
  EnumSet<E> set=EnumSet.noneOf(clazz);
  long mask=1;
  for (  E e : clazz.getEnumConstants()) {
    if ((mask & vector) == mask) {
      set.add(e);
    }
    mask<<=1;
  }
  return set;
}
 

Example 36

From project github-java-sdk, under directory /core/src/test/java/com/github/api/v2/services/.

Source file: OAuthServiceTest.java

  15 
vote

/** 
 * Test get authorization url set.
 */
public void testGetAuthorizationUrlSet(){
  assertNotNullOrEmpty(String.format(RESOURCE_MISSING_MESSAGE,"Test callback URL."),TestConstants.TEST_CALLBACK_URL);
  String authorizationUrl=service.getAuthorizationUrl(TestConstants.TEST_CALLBACK_URL,EnumSet.of(Scope.USER,Scope.REPOSITORY));
  assertNotNullOrEmpty("Authorization URL should not be null.",authorizationUrl);
  try {
    URL url=new URL(authorizationUrl);
    HttpURLConnection request=(HttpURLConnection)url.openConnection();
    if (request.getResponseCode() != HttpURLConnection.HTTP_OK) {
      fail(convertStreamToString(request.getErrorStream()));
    }
  }
 catch (  Exception e) {
    fail(e.getMessage());
  }
}
 

Example 37

From project Gmote, under directory /gmoteserver/src/org/jvlc/.

Source file: MediaPlayer.java

  15 
vote

public void addListener(final MediaPlayerListener listener){
  MediaPlayerCallback callback=new MediaPlayerCallback(this,listener);
  libvlc_exception_t exception=new libvlc_exception_t();
  for (  LibVlcEventType event : EnumSet.range(LibVlcEventType.libvlc_MediaPlayerPlaying,LibVlcEventType.libvlc_MediaPlayerTimeChanged)) {
    libvlc.libvlc_event_attach(eventManager,event.ordinal(),callback,null,exception);
  }
  callbacks.add(callback);
}
 

Example 38

From project google-gson, under directory /src/test/java/com/google/gson/functional/.

Source file: EnumTest.java

  15 
vote

/** 
 * Test for issue 226.
 */
public void testEnumSubclass(){
  assertFalse(Roshambo.class == Roshambo.ROCK.getClass());
  assertEquals("\"ROCK\"",gson.toJson(Roshambo.ROCK));
  assertEquals("[\"ROCK\",\"PAPER\",\"SCISSORS\"]",gson.toJson(EnumSet.allOf(Roshambo.class)));
  assertEquals(Roshambo.ROCK,gson.fromJson("\"ROCK\"",Roshambo.class));
  assertEquals(EnumSet.allOf(Roshambo.class),gson.fromJson("[\"ROCK\",\"PAPER\",\"SCISSORS\"]",new TypeToken<Set<Roshambo>>(){
  }
.getType()));
}
 

Example 39

From project gson, under directory /gson/src/test/java/com/google/gson/functional/.

Source file: EnumTest.java

  15 
vote

/** 
 * Test for issue 226.
 */
public void testEnumSubclass(){
  assertFalse(Roshambo.class == Roshambo.ROCK.getClass());
  assertEquals("\"ROCK\"",gson.toJson(Roshambo.ROCK));
  assertEquals("[\"ROCK\",\"PAPER\",\"SCISSORS\"]",gson.toJson(EnumSet.allOf(Roshambo.class)));
  assertEquals(Roshambo.ROCK,gson.fromJson("\"ROCK\"",Roshambo.class));
  assertEquals(EnumSet.allOf(Roshambo.class),gson.fromJson("[\"ROCK\",\"PAPER\",\"SCISSORS\"]",new TypeToken<Set<Roshambo>>(){
  }
.getType()));
}
 

Example 40

From project hcatalog, under directory /src/java/org/apache/hcatalog/security/.

Source file: HdfsAuthorizationProvider.java

  15 
vote

protected EnumSet<FsAction> getFsActions(Privilege[] privs,Path path){
  EnumSet<FsAction> actions=EnumSet.noneOf(FsAction.class);
  if (privs == null) {
    return actions;
  }
  for (  Privilege priv : privs) {
    actions.add(getFsAction(priv,path));
  }
  return actions;
}
 

Example 41

From project hibernate-validator, under directory /annotation-processor/src/test/java/org/hibernate/validator/ap/.

Source file: ConstraintValidationProcessorTest.java

  15 
vote

/** 
 * HV-575. Make sure that @Past/@Future can be validated for JDK types, also if JodaTime isn't available.
 */
@Test public void modelWithDateConstraintsCanBeProcessedWithoutJodaTimeOnClassPath(){
  File sourceFile=compilerHelper.getSourceFile(ModelWithDateConstraints.class);
  boolean compilationResult=compilerHelper.compile(new ConstraintValidationProcessor(),diagnostics,EnumSet.of(Library.VALIDATION_API),sourceFile);
  assertFalse(compilationResult);
  assertThatDiagnosticsMatch(diagnostics,new DiagnosticExpectation(Kind.ERROR,27));
}
 

Example 42

From project hs4j, under directory /src/main/java/com/google/code/hs4j/network/buffer/.

Source file: AbstractIoBuffer.java

  15 
vote

private <E extends Enum<E>>EnumSet<E> toEnumSet(Class<E> clazz,long vector){
  EnumSet<E> set=EnumSet.noneOf(clazz);
  long mask=1;
  for (  E e : clazz.getEnumConstants()) {
    if ((mask & vector) == mask) {
      set.add(e);
    }
    mask<<=1;
  }
  return set;
}
 

Example 43

From project https-utils, under directory /src/main/java/org/italiangrid/utils/https/.

Source file: JettyAdminService.java

  15 
vote

/** 
 * Creates and starts the shutdown service.
 */
public synchronized void start(){
  if (adminService.isRunning()) {
    throw new IllegalStateException("Admin service is already running");
  }
  ServletContextHandler commandContext=new ServletContextHandler(adminService,"/",false,false);
  commandContext.setDisplayName("Jetty Administration service");
  adminCommands.add(buildShutdownCommand());
  ServletHolder servletHolder;
  for (  AbstractAdminCommand command : adminCommands) {
    servletHolder=new ServletHolder(command);
    commandContext.addServlet(servletHolder,command.getCommandPath());
  }
  if (adminPassword != null) {
    FilterHolder passwordFiler=new FilterHolder(new PasswordProtectFilter(adminPassword));
    commandContext.addFilter(passwordFiler,"/*",EnumSet.of(DispatcherType.REQUEST));
  }
  JettyRunThread shutdownServiceRunThread=new JettyRunThread(adminService);
  shutdownServiceRunThread.start();
}
 

Example 44

From project jaffl, under directory /src/com/kenai/jaffl/provider/.

Source file: AbstractRuntime.java

  15 
vote

public AbstractRuntime(ByteOrder byteOrder,EnumMap<NativeType,Type> typeMap){
  this.byteOrder=byteOrder;
  EnumSet<NativeType> nativeTypes=EnumSet.allOf(NativeType.class);
  types=new Type[nativeTypes.size()];
  for (  NativeType t : nativeTypes) {
    types[t.ordinal()]=typeMap.containsKey(t) ? typeMap.get(t) : new BadType(t);
  }
  this.addressSize=types[NativeType.ADDRESS.ordinal()].size();
  this.longSize=types[NativeType.SLONG.ordinal()].size();
  this.addressMask=addressSize == 4 ? 0xffffffffL : 0xffffffffffffffffL;
}
 

Example 45

From project jboss-as-quickstart, under directory /cluster-ha-singleton/service/src/main/java/org/jboss/as/quickstarts/cluster/hasingleton/service/ejb/.

Source file: Init.java

  15 
vote

/** 
 * Create the Service and wait until it is started.<br/> Will log a message if the service will not start in 10sec.
 */
@PostConstruct protected void startup(){
  LOGGER.info("StartupSingleton will be initialized!");
  HATimerService service=new HATimerService();
  SingletonService<String> singleton=new SingletonService<String>(service,HATimerService.SINGLETON_SERVICE_NAME);
  ServiceController<String> controller=singleton.build(CurrentServiceContainer.getServiceContainer()).addDependency(ServerEnvironmentService.SERVICE_NAME,ServerEnvironment.class,service.env).install();
  controller.setMode(ServiceController.Mode.ACTIVE);
  try {
    wait(controller,EnumSet.of(ServiceController.State.DOWN,ServiceController.State.STARTING),ServiceController.State.UP);
    LOGGER.info("StartupSingleton has started the Service");
  }
 catch (  IllegalStateException e) {
    LOGGER.warn("Singleton Service {} not started, are you sure to start in a cluster (HA) environment?",HATimerService.SINGLETON_SERVICE_NAME);
  }
}
 

Example 46

From project jboss-logmanager, under directory /src/main/java/org/jboss/logmanager/.

Source file: ConcurrentReferenceHashMap.java

  15 
vote

/** 
 * Creates a new, empty map with the specified initial capacity, reference types, load factor and concurrency level. Behavioral changing options such as  {@link Option#IDENTITY_COMPARISONS}can also be specified.
 * @param initialCapacity the initial capacity. The implementationperforms internal sizing to accommodate this many elements.
 * @param loadFactor  the load factor threshold, used to control resizing.Resizing may be performed when the average number of elements per bin exceeds this threshold.
 * @param concurrencyLevel the estimated number of concurrentlyupdating threads. The implementation performs internal sizing to try to accommodate this many threads.
 * @param keyType the reference type to use for keys
 * @param valueType the reference type to use for values
 * @param options the behavioral options
 * @throws IllegalArgumentException if the initial capacity isnegative or the load factor or concurrencyLevel are nonpositive.
 */
public ConcurrentReferenceHashMap(int initialCapacity,float loadFactor,int concurrencyLevel,ReferenceType keyType,ReferenceType valueType,EnumSet<Option> options){
  if (!(loadFactor > 0) || initialCapacity < 0 || concurrencyLevel <= 0)   throw new IllegalArgumentException();
  if (concurrencyLevel > MAX_SEGMENTS)   concurrencyLevel=MAX_SEGMENTS;
  int sshift=0;
  int ssize=1;
  while (ssize < concurrencyLevel) {
    ++sshift;
    ssize<<=1;
  }
  segmentShift=32 - sshift;
  segmentMask=ssize - 1;
  this.segments=Segment.newArray(ssize);
  if (initialCapacity > MAXIMUM_CAPACITY)   initialCapacity=MAXIMUM_CAPACITY;
  int c=initialCapacity / ssize;
  if (c * ssize < initialCapacity)   ++c;
  int cap=1;
  while (cap < c)   cap<<=1;
  identityComparisons=options != null && options.contains(Option.IDENTITY_COMPARISONS);
  for (int i=0; i < this.segments.length; ++i)   this.segments[i]=new Segment<K,V>(cap,loadFactor,keyType,valueType,identityComparisons);
}
 

Example 47

From project jboss-modules, under directory /src/main/java/org/jboss/modules/.

Source file: ModuleXmlParser.java

  15 
vote

private static void parseModuleAbsentContents(final XMLStreamReader reader,final ModuleIdentifier moduleIdentifier) throws XMLStreamException {
  final int count=reader.getAttributeCount();
  String name=null;
  String slot=null;
  final Set<Attribute> required=EnumSet.of(Attribute.NAME,Attribute.TARGET_NAME);
  for (int i=0; i < count; i++) {
    final Attribute attribute=Attribute.of(reader.getAttributeName(i));
    required.remove(attribute);
switch (attribute) {
case NAME:
      name=reader.getAttributeValue(i);
    break;
case SLOT:
  slot=reader.getAttributeValue(i);
break;
default :
throw unexpectedContent(reader);
}
}
if (!required.isEmpty()) {
throw missingAttributes(reader.getLocation(),required);
}
if (!moduleIdentifier.equals(ModuleIdentifier.create(name,slot))) {
throw invalidModuleName(reader.getLocation(),moduleIdentifier);
}
while (reader.hasNext()) {
switch (reader.nextTag()) {
case END_ELEMENT:
{
return;
}
default :
{
throw unexpectedContent(reader);
}
}
}
throw endOfDocument(reader.getLocation());
}
 

Example 48

From project jcommander, under directory /src/main/java/com/beust/jcommander/.

Source file: ParameterDescription.java

  15 
vote

@SuppressWarnings("unchecked") private void init(Object object,Parameterized parameterized,ResourceBundle bundle,JCommander jCommander){
  m_object=object;
  m_parameterized=parameterized;
  m_bundle=bundle;
  if (m_bundle == null) {
    m_bundle=findResourceBundle(object);
  }
  m_jCommander=jCommander;
  if (m_parameterAnnotation != null) {
    String description;
    if (Enum.class.isAssignableFrom(parameterized.getType()) && m_parameterAnnotation.description().isEmpty()) {
      description="Options: " + EnumSet.allOf((Class<? extends Enum>)parameterized.getType());
    }
 else {
      description=m_parameterAnnotation.description();
    }
    initDescription(description,m_parameterAnnotation.descriptionKey(),m_parameterAnnotation.names());
  }
 else   if (m_dynamicParameterAnnotation != null) {
    initDescription(m_dynamicParameterAnnotation.description(),m_dynamicParameterAnnotation.descriptionKey(),m_dynamicParameterAnnotation.names());
  }
 else {
    throw new AssertionError("Shound never happen");
  }
  try {
    m_default=parameterized.get(object);
  }
 catch (  Exception e) {
  }
  if (m_default != null) {
    if (m_parameterAnnotation != null) {
      validateDefaultValues(m_parameterAnnotation.names());
    }
  }
}
 

Example 49

From project jdg, under directory /infinispan/src/main/java/org/jboss/as/clustering/infinispan/subsystem/.

Source file: CacheConfigOperationHandlers.java

  15 
vote

@Override public void registerAttributes(final ManagementResourceRegistration registry){
  final EnumSet<AttributeAccess.Flag> flags=EnumSet.of(AttributeAccess.Flag.RESTART_ALL_SERVICES);
  for (  AttributeDefinition attr : attributes) {
    registry.registerReadWriteAttribute(attr.getName(),null,this,flags);
  }
}
 

Example 50

From project jena-fuseki, under directory /src/main/java/org/apache/jena/fuseki/server/.

Source file: SPARQLServer.java

  15 
vote

private static void addServlet(ServletContextHandler context,ServletHolder holder,String pathSpec,boolean enableCompression){
  if (serverLog.isDebugEnabled()) {
    if (enableCompression)     serverLog.debug("Add servlet @ " + pathSpec + " (with gzip)");
 else     serverLog.debug("Add servlet @ " + pathSpec);
  }
  context.addServlet(holder,pathSpec);
  if (enableCompression)   context.addFilter(GzipFilter.class,pathSpec,EnumSet.allOf(DispatcherType.class));
}
 

Example 51

From project JGit, under directory /org.spearce.jgit/src/org/spearce/jgit/revwalk/.

Source file: RevWalk.java

  15 
vote

/** 
 * Create a new revision walker for a given repository.
 * @param repo the repository the walker will obtain data from.
 */
public RevWalk(final Repository repo){
  db=repo;
  curs=new WindowCursor();
  idBuffer=new MutableObjectId();
  objects=new ObjectIdSubclassMap<RevObject>();
  roots=new ArrayList<RevCommit>();
  queue=new DateRevQueue();
  pending=new StartGenerator(this);
  sorting=EnumSet.of(RevSort.NONE);
  filter=RevFilter.ALL;
  treeFilter=TreeFilter.ALL;
}
 

Example 52

From project jira-rest-java-client, under directory /atlassian-jira-rest-java-client/src/test/java/it/.

Source file: JerseyIssueRestClientTest.java

  15 
vote

@Test public void testGetIssue() throws Exception {
  final Issue issue=client.getIssueClient().getIssue("TST-1",pm);
  assertEquals("TST-1",issue.getKey());
  assertTrue(issue.getSelf().toString().startsWith(jiraUri.toString()));
  assertEqualsNoUri(IntegrationTestUtil.USER_ADMIN,issue.getReporter());
  assertEqualsNoUri(IntegrationTestUtil.USER_ADMIN,issue.getAssignee());
  assertEquals(3,Iterables.size(issue.getComments()));
  final Iterable<String> expectedExpandos=isJira5xOrNewer() ? ImmutableList.of("renderedFields","names","schema","transitions","operations","editmeta","changelog") : ImmutableList.of("html");
  assertThat(ImmutableList.copyOf(issue.getExpandos()),IterableMatcher.hasOnlyElements(expectedExpandos));
  assertEquals(new TimeTracking(null,0,190),issue.getTimeTracking());
  assertTrue(Iterables.size(issue.getFields()) > 0);
  assertEquals(IntegrationTestUtil.START_PROGRESS_TRANSITION_ID,Iterables.size(issue.getAttachments()));
  final Iterable<Attachment> items=issue.getAttachments();
  assertNotNull(items);
  Attachment attachment1=new Attachment(IntegrationTestUtil.concat(IntegrationTestUtil.TESTING_JIRA_5_OR_NEWER ? UriBuilder.fromUri(jiraUri).path("/rest/api/2/").build() : jiraRestRootUri,"/attachment/10040"),"dla Paw\u0142a.txt",IntegrationTestUtil.USER_ADMIN,dateTime,643,"text/plain",IntegrationTestUtil.concat(jiraUri,"/secure/attachment/10040/dla+Paw%C5%82a.txt"),null);
  assertEquals(attachment1,items.iterator().next());
  assertNull(issue.getChangelog());
  final Issue issueWithChangelog=client.getIssueClient().getIssue("TST-2",EnumSet.of(IssueRestClient.Expandos.CHANGELOG),pm);
  final Iterable<ChangelogGroup> changelog=issueWithChangelog.getChangelog();
  if (isJira5xOrNewer()) {
    assertNotNull(changelog);
    final ChangelogGroup chg1=Iterables.get(changelog,18);
    assertEquals("admin",chg1.getAuthor().getName());
    assertEquals("Administrator",chg1.getAuthor().getDisplayName());
    assertEquals(new DateTime(2010,8,17,16,40,34,924).toInstant(),chg1.getCreated().toInstant());
    assertEquals(Collections.singletonList(new ChangelogItem(ChangelogItem.FieldType.JIRA,"status","1","Open","3","In Progress")),chg1.getItems());
    final ChangelogGroup chg2=Iterables.get(changelog,20);
    assertEquals("admin",chg2.getAuthor().getName());
    assertEquals("Administrator",chg2.getAuthor().getDisplayName());
    assertEquals(new DateTime(2010,8,24,16,10,23,468).toInstant(),chg2.getCreated().toInstant());
    final List<ChangelogItem> expected=ImmutableList.of(new ChangelogItem(ChangelogItem.FieldType.JIRA,"timeoriginalestimate",null,null,"0","0"),new ChangelogItem(ChangelogItem.FieldType.CUSTOM,"My Radio buttons",null,null,null,"Another"),new ChangelogItem(ChangelogItem.FieldType.CUSTOM,"project3",null,null,"10000","Test Project"),new ChangelogItem(ChangelogItem.FieldType.CUSTOM,"My Number Field New",null,null,null,"1.45"));
    assertEquals(expected,chg2.getItems());
  }
}
 

Example 53

From project JKismet, under directory /src/za/co/towerman/jkismet/message/.

Source file: BSSIDMessage.java

  15 
vote

@Capability("carrierset") public void setCarriers(int carriers){
  this.carriers=EnumSet.noneOf(CarrierType.class);
  for (int i=0; i < CarrierType.values().length; ++i) {
    if (((carriers >>> i) & 0x01) > 0) {
      this.carriers.add(CarrierType.values()[i]);
    }
  }
}
 

Example 54

From project json-schema-validator, under directory /src/main/java/org/eel/kitchen/jsonschema/keyword/.

Source file: AbstractTypeKeywordValidator.java

  15 
vote

/** 
 * Add a simple type to  {@link #typeSet}<p>There are two special cases:</p> <ul> <li>if type is  {@link #ANY}, all values are filled in;</li> <li>if type is  {@code number}, it also covers  {@code integer}.</li> </ul>
 * @param type the type as a string
 */
private void addSimpleType(final String type){
  if (ANY.equals(type)) {
    typeSet.addAll(EnumSet.allOf(NodeType.class));
    return;
  }
  final NodeType tmp=NodeType.fromName(type);
  typeSet.add(tmp);
  if (tmp == NodeType.NUMBER)   typeSet.add(NodeType.INTEGER);
}
 

Example 55

From project juel, under directory /modules/impl/src/main/java/de/odysseus/el/.

Source file: ExpressionFactoryImpl.java

  15 
vote

/** 
 * Create the factory's tree store. This implementation creates a new tree store using the default builder and cache implementations. The builder and cache are configured using the specified properties. The maximum cache size will be as specified unless overridden by property <code>javax.el.cacheSize</code>.
 */
protected TreeStore createTreeStore(int defaultCacheSize,Profile profile,Properties properties){
  TreeBuilder builder=null;
  if (properties == null) {
    builder=createTreeBuilder(null,profile.features());
  }
 else {
    EnumSet<Builder.Feature> features=EnumSet.noneOf(Builder.Feature.class);
    if (getFeatureProperty(profile,properties,Feature.METHOD_INVOCATIONS,PROP_METHOD_INVOCATIONS)) {
      features.add(Builder.Feature.METHOD_INVOCATIONS);
    }
    if (getFeatureProperty(profile,properties,Feature.VARARGS,PROP_VAR_ARGS)) {
      features.add(Builder.Feature.VARARGS);
    }
    if (getFeatureProperty(profile,properties,Feature.NULL_PROPERTIES,PROP_NULL_PROPERTIES)) {
      features.add(Builder.Feature.NULL_PROPERTIES);
    }
    if (getFeatureProperty(profile,properties,Feature.IGNORE_RETURN_TYPE,PROP_IGNORE_RETURN_TYPE)) {
      features.add(Builder.Feature.IGNORE_RETURN_TYPE);
    }
    builder=createTreeBuilder(properties,features.toArray(new Builder.Feature[0]));
  }
  int cacheSize=defaultCacheSize;
  if (properties != null && properties.containsKey(PROP_CACHE_SIZE)) {
    try {
      cacheSize=Integer.parseInt(properties.getProperty(PROP_CACHE_SIZE));
    }
 catch (    NumberFormatException e) {
      throw new ELException("Cannot parse EL property " + PROP_CACHE_SIZE,e);
    }
  }
  Cache cache=cacheSize > 0 ? new Cache(cacheSize) : null;
  return new TreeStore(builder,cache);
}
 

Example 56

From project karaf, under directory /features/command/src/main/java/org/apache/karaf/features/command/.

Source file: InstallFeatureCommand.java

  15 
vote

protected void doExecute(FeaturesService admin) throws Exception {
  for (  String feature : features) {
    String[] split=feature.split("/");
    String name=split[0];
    String version=null;
    if (split.length == 2) {
      version=split[1];
    }
    if (version == null || version.length() == 0) {
      version=DEFAULT_VERSION;
    }
    EnumSet<FeaturesService.Option> options=EnumSet.of(FeaturesService.Option.PrintBundlesToRefresh);
    if (noRefresh) {
      options.add(FeaturesService.Option.NoAutoRefreshBundles);
    }
    if (noClean) {
      options.add(FeaturesService.Option.NoCleanIfFailure);
    }
    if (verbose) {
      options.add(FeaturesService.Option.Verbose);
    }
    admin.installFeature(name,version,options);
  }
}