下面列出了java.util.EnumSet#range ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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);
}
}
}
@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);
}
}
}
}
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
);
}
}
@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);
}
}
}
}
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
);
}
}
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
);
}
}
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
);
}
}
/**
* 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");
}
}
/**
* 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");
}
}
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));
}
}
/**
* 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");
}
}
/**
* 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");
}
}
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;
}
/**
* 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");
}
}
@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();
}
}
}
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);
}
}
/**
* 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();
}
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;
}
<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);
}
}
}
public static EnumSet<Gain> getSensitivityGains()
{
return EnumSet.range( SENSITIVITY_1, SENSITIVITY_22 );
}