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

The following examples show how to use java.util.EnumSet#range() . 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: MinguoCalendar.java    From Time4A with Apache License 2.0 6 votes vote down vote up
private static void registerUnits(TimeAxis.Builder<CalendarUnit, MinguoCalendar> builder) {

        Set<CalendarUnit> monthly =
            EnumSet.range(CalendarUnit.MILLENNIA, CalendarUnit.MONTHS);
        Set<CalendarUnit> daily =
            EnumSet.range(CalendarUnit.WEEKS, CalendarUnit.DAYS);

        for (CalendarUnit unit : CalendarUnit.values()) {
            builder.appendUnit(
                unit,
                new MinguoUnitRule(unit),
                unit.getLength(),
                (unit.compareTo(CalendarUnit.WEEKS) < 0) ? monthly : daily
            );
        }

    }
 
Example 2
Source File: PlainTimestamp.java    From Time4A with Apache License 2.0 6 votes vote down vote up
private static void registerCalendarUnits(
    TimeAxis.Builder<IsoUnit, PlainTimestamp> builder
) {

    Set<CalendarUnit> monthly = EnumSet.range(MILLENNIA, MONTHS);
    Set<CalendarUnit> daily = EnumSet.range(WEEKS, DAYS);

    for (CalendarUnit unit : CalendarUnit.values()) {
        builder.appendUnit(
            unit,
            new CompositeUnitRule(unit),
            unit.getLength(),
            (unit.compareTo(WEEKS) < 0) ? monthly : daily
        );
    }

}
 
Example 3
Source File: JucheCalendar.java    From Time4A with Apache License 2.0 6 votes vote down vote up
private static void registerUnits(TimeAxis.Builder<CalendarUnit, JucheCalendar> builder) {

        Set<CalendarUnit> monthly =
            EnumSet.range(CalendarUnit.MILLENNIA, CalendarUnit.MONTHS);
        Set<CalendarUnit> daily =
            EnumSet.range(CalendarUnit.WEEKS, CalendarUnit.DAYS);

        for (CalendarUnit unit : CalendarUnit.values()) {
            builder.appendUnit(
                unit,
                new JucheUnitRule(unit),
                unit.getLength(),
                (unit.compareTo(CalendarUnit.WEEKS) < 0) ? monthly : daily
            );
        }

    }
 
Example 4
Source File: PlainDate.java    From Time4A with Apache License 2.0 6 votes vote down vote up
private static void registerUnits(TimeAxis.Builder<IsoDateUnit, PlainDate> builder) {

        Set<CalendarUnit> monthly =
            EnumSet.range(CalendarUnit.MILLENNIA, CalendarUnit.MONTHS);
        Set<CalendarUnit> daily =
            EnumSet.range(CalendarUnit.WEEKS, CalendarUnit.DAYS);

        for (CalendarUnit unit : CalendarUnit.values()) {
            builder.appendUnit(
                unit,
                new CalendarUnit.Rule<PlainDate>(unit),
                unit.getLength(),
                (unit.compareTo(CalendarUnit.WEEKS) < 0) ? monthly : daily
            );
        }

    }
 
Example 5
Source File: ActivityFinisher.java    From material-activity-chooser with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    List<Activity> activities = new ArrayList<>();

    for (Stage s : EnumSet.range(Stage.CREATED, Stage.STOPPED)) {
        activities.addAll(mLifecycleMonitor.getActivitiesInStage(s));
    }

    Log.i(TAG, "Activities that are still in CREATED to STOPPED: " + activities.size());

    for (Activity activity : activities) {
        if (!activity.isFinishing()) {
            try {
                Log.i(TAG, "Finishing mActivityRule: " + activity);
                activity.finish();
            } catch (RuntimeException e) {
                Log.e(TAG, "Failed to finish mActivityRule.", e);
            }
        }
    }
}
 
Example 6
Source File: MonitoringInstrumentation.java    From android-test with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
  List<Activity> activities = new ArrayList<>();

  for (Stage s : EnumSet.range(Stage.CREATED, Stage.STOPPED)) {
    activities.addAll(lifecycleMonitor.getActivitiesInStage(s));
  }

  if (activities.size() > 0) {
    Log.i(TAG, "Activities that are still in CREATED to STOPPED: " + activities.size());
  }

  for (Activity activity : activities) {
    if (!activity.isFinishing()) {
      try {
        Log.i(TAG, "Finishing activity: " + activity);
        activity.finish();
      } catch (RuntimeException e) {
        Log.e(TAG, "Failed to finish activity.", e);
      }
    }
  }
}
 
Example 7
Source File: InterController.java    From audiveris with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Background epilog for any user action sequence.
 *
 * @param seq sequence of user tasks
 */
protected void epilog (UITaskList seq)
{
    if (opKind == OpKind.DO) {
        sheet.getStub().setModified(true);
    }

    // Re-process impacted steps
    final Step latestStep = sheet.getStub().getLatestStep();
    final Step firstStep = firstImpactedStep(seq);
    logger.debug("firstStep: {}", firstStep);

    if ((firstStep != null) && (firstStep.compareTo(latestStep) <= 0)) {
        final EnumSet<Step> steps = EnumSet.range(firstStep, latestStep);

        for (Step step : steps) {
            logger.debug("Impact {}", step);
            step.impact(seq, opKind);
        }
    }
}
 
Example 8
Source File: GetSourceVersionsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verify getSourceVersions.
 */
@Test
public void testRun() throws Exception {
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    Set<SourceVersion> found = tool.getSourceVersions();
    Set<SourceVersion> expect = EnumSet.range(SourceVersion.RELEASE_3, SourceVersion.latest());
    if (!expect.equals(found)) {
        System.err.println("expect: " + expect);
        System.err.println(" found: " + expect);
        error("unexpected versions");
    }
}
 
Example 9
Source File: SheetStub.java    From audiveris with GNU Affero General Public License v3.0 5 votes vote down vote up
private EnumSet<Step> getNeededSteps (Step target)
{
    EnumSet<Step> neededSteps = EnumSet.noneOf(Step.class);

    // Add all needed steps
    for (Step step : EnumSet.range(Step.first(), target)) {
        if (!isDone(step)) {
            neededSteps.add(step);
        }
    }

    return neededSteps;
}
 
Example 10
Source File: GetSourceVersionsTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verify getSourceVersions.
 */
@Test
public void testRun() throws Exception {
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    Set<SourceVersion> found = tool.getSourceVersions();
    Set<SourceVersion> expect = EnumSet.range(SourceVersion.RELEASE_3, SourceVersion.latest());
    if (!expect.equals(found)) {
        System.err.println("expect: " + expect);
        System.err.println(" found: " + expect);
        error("unexpected versions");
    }
}
 
Example 11
Source File: GetSourceVersionsTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verify getSourceVersions.
 */
@Test
public void testRun() throws Exception {
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    Set<SourceVersion> found = tool.getSourceVersions();
    Set<SourceVersion> expect = EnumSet.range(SourceVersion.RELEASE_3, SourceVersion.latest());
    if (!expect.equals(found)) {
        System.err.println("expect: " + expect);
        System.err.println(" found: " + expect);
        error("unexpected versions");
    }
}
 
Example 12
Source File: AccountingPeriodMonthTest.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
private void assertAccountingPeriodMonthEqual(Set<String> periodCodes, AccountingPeriodMonth beginPeriod, AccountingPeriodMonth endPeriod) {
    Set<AccountingPeriodMonth> accountingPeriodMonth = EnumSet.range(beginPeriod, endPeriod);
    assertTrue(periodCodes.size() == accountingPeriodMonth.size());

    for (String code : periodCodes) {
        AccountingPeriodMonth month = AccountingPeriodMonth.findAccountingPeriod(code);
        assertTrue(accountingPeriodMonth.contains(month));
    }
}
 
Example 13
Source File: GetSourceVersionsTest.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verify getSourceVersions.
 */
@Test
public void testRun() throws Exception {
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    Set<SourceVersion> found = tool.getSourceVersions();
    Set<SourceVersion> expect = EnumSet.range(SourceVersion.RELEASE_3, SourceVersion.latest());
    if (!expect.equals(found)) {
        System.err.println("expect: " + expect);
        System.err.println(" found: " + expect);
        error("unexpected versions");
    }
}
 
Example 14
Source File: ActivityFinisher.java    From CleanGUITestArchitecture with MIT License 5 votes vote down vote up
@Override
public void run() {
    final List<Activity> activities = new ArrayList<>();

    for (final Stage stage : EnumSet.range(Stage.CREATED, Stage.STOPPED)) {
        activities.addAll(activityLifecycleMonitor.getActivitiesInStage(stage));
    }

    for (final Activity activity : activities) {
        if (!activity.isFinishing()) {
            activity.finish();
        }
    }
}
 
Example 15
Source File: PartitionTreePriorPanel.java    From beast-mcmc with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void setTreePriorChoices(boolean isMultiLocus, boolean isTipCalibrated) {
    TreePriorType type = (TreePriorType) treePriorCombo.getSelectedItem();
    treePriorCombo.removeAllItems();


    for (TreePriorType treePriorType : EnumSet.range(TreePriorType.CONSTANT, TreePriorType.BIRTH_DEATH_SERIAL_SAMPLING)) {
        treePriorCombo.addItem(treePriorType);
    }

    // REMOVED due to unresolved issues with model
    // treePriorCombo.addItem(TreePriorType.BIRTH_DEATH_BASIC_REPRODUCTIVE_NUMBER);


    // would be much better to disable these rather than removing them
    if (isMultiLocus) {
        treePriorCombo.removeItem(TreePriorType.SKYLINE);
    }

    if (isTipCalibrated) {
        // remove models that require contemporaneous tips...
        treePriorCombo.removeItem(TreePriorType.YULE);
        treePriorCombo.removeItem(TreePriorType.YULE_CALIBRATION);
        treePriorCombo.removeItem(TreePriorType.BIRTH_DEATH);
        treePriorCombo.removeItem(TreePriorType.BIRTH_DEATH_INCOMPLETE_SAMPLING);
    }

    // this makes sure treePriorCombo selects correct prior
    treePriorCombo.setSelectedItem(type);
    if (treePriorCombo.getSelectedItem() == null) {
        treePriorCombo.setSelectedIndex(0);
    }
}
 
Example 16
Source File: EquipmentBuilderFacadeImpl.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Create a new EquipmentBuilderFacadeImpl instance for the customization of 
 * a particular item of equipment for the character.
 * @param equip The equipment item being customized (must not be the base item).
 * @param character The character the equipment will be for.
 * @param delegate The handler for UI functions such as dialogs.
 */
EquipmentBuilderFacadeImpl(Equipment equip, PlayerCharacter character, UIDelegate delegate)
{
	this.equip = equip;
	this.character = character;
	this.delegate = delegate;

	sizeRef = new DefaultReferenceFacade<>(equip.getSizeAdjustment());

	final String sBaseKey = equip.getBaseItemKeyName();
	baseEquipment =
			Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Equipment.class, sBaseKey);

	equipHeads = equip.isDouble() ? EnumSet.range(EquipmentHead.PRIMARY, EquipmentHead.SECONDARY)
		: EnumSet.of(EquipmentHead.PRIMARY);

	availListMap = new HashMap<>();
	selectedListMap = new HashMap<>();
	for (EquipmentHead head : equipHeads)
	{
		availListMap.put(head, new DefaultListFacade<>());
		DefaultListFacade<EquipmentModifier> selectedList = new DefaultListFacade<>();
		selectedList.setContents(equip.getEqModifierList(head.isPrimary()));
		selectedListMap.put(head, selectedList);
	}
	refreshAvailList();
}
 
Example 17
Source File: GetSourceVersionsTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verify getSourceVersions.
 */
@Test
public void testRun() throws Exception {
    DocumentationTool tool = ToolProvider.getSystemDocumentationTool();
    Set<SourceVersion> found = tool.getSourceVersions();
    Set<SourceVersion> expect = EnumSet.range(SourceVersion.RELEASE_3, SourceVersion.latest());
    if (!expect.equals(found)) {
        System.err.println("expect: " + expect);
        System.err.println(" found: " + expect);
        error("unexpected versions");
    }
}
 
Example 18
Source File: ShadBala.java    From Astrosoft with GNU General Public License v2.0 4 votes vote down vote up
private EnumMap<Planet, Double> calcChestabala() {

		double utime = birthData.birthTime()
				+ ((5 + (double) (4.00 / 60.00)) - birthData.timeZone());
		double interval = epochDays + (double) (utime / 24.00);
		double[] madhya = new double[7];
		double[] seegh = new double[7];
		double correction;
		double ck;

		// System.out.println("Interval : " + interval + " BT " +
		// AstroUtil.dms(birthData.birthTime()) + " UT: " + AstroUtil.dms(utime)
		// );
		madhya[0] = madhya[3] = madhya[5] = ((interval * 0.9855931) + 257.4568) % 360;
		madhya[2] = ((interval * 0.5240218) + 270.22) % 360;
		correction = 3.33 + (0.0067 * (birthYear - 1900));
		madhya[4] = (((interval * 0.08310024) + 220.04) - correction) % 360;
		correction = 5 + (0.001 * (birthYear - 1900));
		madhya[6] = ((interval * 0.03333857) + 236.74 + correction) % 360;
		seegh[2] = seegh[4] = seegh[6] = madhya[0];
		correction = 6.670 + (0.00133 * (birthYear - 1900));
		seegh[3] = ((interval * 4.092385) + 164.00 + correction) % 360;
		correction = 5 + (0.0001 * (birthYear - 1900));
		seegh[5] = (((interval * 1.602159) + 328.51) - correction) % 360;
		ck = (planetPosition.get(Planet.Sun) + ayanamsa + 90) % 360;

		if (ck > 180.00) {
			ck = 360 - ck;
		}

		EnumMap<Planet, Double> ChestaBala = new EnumMap<Planet, Double>(
				Planet.class);

		ChestaBala.put(Planet.Sun, ck / 3.00);
		ck = (planetPosition.get(Planet.Moon) - planetPosition.get(Planet.Sun));

		if (ck < 0) {
			ck = ck + 360;
		}

		if (ck > 180.00) {
			ck = 360 - ck;
		}

		ChestaBala.put(Planet.Moon, ck / 3.00);

		for (Planet p : EnumSet.range(Planet.Mars, Planet.Saturn)) {

			ck = (seegh[p.ordinal()] - ((madhya[p.ordinal()] + planetPosition
					.get(p)) / 2.0));

			if (ck < 360.00) {
				ck = ck + 360;
			}

			ck = ck % 360;

			if (ck > 180.00) {
				ck = 360 - ck;
			}

			ChestaBala.put(p, ck / 3.00);

			// System.out.println(DisplayConsts.planetNames[0][pl] + " Madhya: "
			// + madhya[pl] + " Seeghrochcha: " + seegh[pl]);
			// System.out.println(DisplayConsts.planetNames[0][pl] + "
			// ChestaKendra: " + ck + " PlanetPos: " + h.planetPositions[pl]);
		}

		return ChestaBala;

	}
 
Example 19
Source File: AirspyDevice.java    From FoxTelem with GNU General Public License v3.0 4 votes vote down vote up
public static EnumSet<Gain> getSensitivityGains()
{
	return EnumSet.range( SENSITIVITY_1, SENSITIVITY_22 );
}
 
Example 20
Source File: StateRegistry.java    From Velocity with MIT License 4 votes vote down vote up
<P extends MinecraftPacket> void register(Class<P> clazz, Supplier<P> packetSupplier,
                                          PacketMapping... mappings) {
  if (mappings.length == 0) {
    throw new IllegalArgumentException("At least one mapping must be provided.");
  }

  for (int i = 0; i < mappings.length; i++) {
    PacketMapping current = mappings[i];
    PacketMapping next = (i + 1 < mappings.length) ? mappings[i + 1] : current;
    ProtocolVersion from = current.protocolVersion;
    ProtocolVersion to = current == next ? getLast(SUPPORTED_VERSIONS) : next.protocolVersion;

    if (from.compareTo(to) >= 0 && from != getLast(SUPPORTED_VERSIONS)) {
      throw new IllegalArgumentException(String.format(
          "Next mapping version (%s) should be lower then current (%s)", to, from));
    }

    for (ProtocolVersion protocol : EnumSet.range(from, to)) {
      if (protocol == to && next != current) {
        break;
      }
      ProtocolRegistry registry = this.versions.get(protocol);
      if (registry == null) {
        throw new IllegalArgumentException("Unknown protocol version "
            + current.protocolVersion);
      }

      if (registry.packetIdToSupplier.containsKey(current.id)) {
        throw new IllegalArgumentException("Can not register class " + clazz.getSimpleName()
            + " with id " + current.id + " for " + registry.version
            + " because another packet is already registered");
      }

      if (registry.packetClassToId.containsKey(clazz)) {
        throw new IllegalArgumentException(clazz.getSimpleName()
            + " is already registered for version " + registry.version);
      }

      if (!current.encodeOnly) {
        registry.packetIdToSupplier.put(current.id, packetSupplier);
      }
      registry.packetClassToId.put(clazz, current.id);
    }
  }
}