本文整理汇总了Java中org.apache.commons.lang3.Range.between方法的典型用法代码示例。如果您正苦于以下问题:Java Range.between方法的具体用法?Java Range.between怎么用?Java Range.between使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.Range
的用法示例。
在下文中一共展示了Range.between方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: containmentTest
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
private ContainsTest containmentTest(final double doubleStarts, final double doubleEnds) {
ContainsTest containsTest = null;
if(start<end){
containsTest = new ContainsTest(){
final Range<Double> range = Range.between(doubleStarts, doubleEnds);
@Override
public boolean contains(Double dateAsDouble) {
return range.contains(dateAsDouble);
}
};
}else{
containsTest = new ContainsTest(){
final Range<Double> range = Range.between(doubleStarts, doubleEnds);
@Override
public boolean contains(Double dateAsDouble) {
return !range.contains(dateAsDouble);
}
};
}
return containsTest;
}
示例2: calculatePayPeriod
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
public Range<LocalDateTime> calculatePayPeriod(LocalDateTime dateTime) {
int todayDayOfWeekNumber = dateTime.getDayOfWeek();
int endingDifference = endingDayOfWeek.getDayNumber() - todayDayOfWeekNumber;
int beginningDifference = beginningDayOfWeek.getDayNumber() - todayDayOfWeekNumber;
LocalDateTime beginningDateTime = calculateEndingDateTime(dateTime, beginningDifference).toDateTime().withTimeAtStartOfDay().toLocalDateTime();
LocalDateTime endingDateTime = calculateBeginningDateTime(dateTime, endingDifference).toDateTime().withTimeAtStartOfDay().plusHours(23).plusMinutes(59).plusSeconds(59).toLocalDateTime();
return Range.between(beginningDateTime, endingDateTime, LocalDateTime::compareTo);
}
示例3: inventory
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
/**
* Utility method to add the entire main inventory of a player to the slot list.
* Note that this does not include the hotbar nor the armor slots.
*
* @param xStart the horizontal position at which the inventory begins
* @param yStart the vertical position at which the inventory begins
* @return a reference to this {@code ContainerPlayerInventoryBuilder} to resume the "Builder" pattern
*/
public ContainerPlayerInventoryBuilder inventory(final int xStart, final int yStart)
{
final int startIndex = this.parent.slots.size();
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 9; ++j)
this.parent.slots.add(new ListenerSlot(this.player, j + i * 9 + 9, xStart + j * 18, yStart + i * 18));
this.main = Range.between(startIndex, this.parent.slots.size() - 1);
return this;
}
示例4: hotbar
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
/**
* Utility method to add the entire hotbar of a player to the slot list.
*
* @param xStart the horizontal position at which the inventory begins
* @param yStart the vertical position at which the inventory begins
* @return a reference to this {@code ContainerPlayerInventoryBuilder} to resume the "Builder" pattern
*/
public ContainerPlayerInventoryBuilder hotbar(final int xStart, final int yStart)
{
final int startIndex = this.parent.slots.size();
for (int i = 0; i < 9; ++i)
this.parent.slots.add(new ListenerSlot(this.player, i, xStart + i * 18, yStart));
this.hotbar = Range.between(startIndex, this.parent.slots.size() - 1);
return this;
}
示例5: main
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
/**
* @param args
*/
public static void main(String[] args) {
RandomArrayGenerator newRandomNumGen = new RandomArrayGenerator();
Range<Double> range = Range.between(-5.12, 5.12);
double[] randomArray = newRandomNumGen.getRandomArrayDouble(range, 30,"Spherical");
for (int i = 0; i < randomArray.length; i++) {
System.out
.println("Array Value for " + i + " is " + randomArray[i]);
}
}
示例6: toIntervals
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
/**
* Compute the set of sorted (oldest to newest) window intervals relative to the passed timestamp
* given inclusion and exclusion predicates.
*
* @param now
* @return intervals returns a set of sorted (oldest to newest) window intervals relative to the
* passed timestamp given inclusion and exclusion predicates.
*/
public List<Range<Long>> toIntervals(long now) {
List<Range<Long>> intervals = new ArrayList<>();
long startMillis = getStartMillis(now);
long endMillis = getEndMillis(now);
Iterable<Predicate<Long>> includes = getIncludes(now);
Iterable<Predicate<Long>> excludes = getExcludes(now);
//if we don't have a skip distance, then we just skip past everything to make the window dense
long skipDistance = getSkipDistance().orElse(Long.MAX_VALUE);
//if we don't have a window width, then we want the window to be completely dense.
Optional<Long> binWidthOpt = getBinWidth();
long binWidth = binWidthOpt.isPresent()?binWidthOpt.get():endMillis-startMillis;
for(long left = startMillis;left >= 0 && left + binWidth <= endMillis;left += skipDistance) {
Range<Long> interval = Range.between(left, left + binWidth);
boolean include = includes.iterator().hasNext()?false:true;
for(Predicate<Long> inclusionPredicate : includes) {
include |= inclusionPredicate.test(left);
}
if(include) {
for(Predicate<Long> exclusionPredicate : excludes) {
include &= !exclusionPredicate.test(left);
}
}
if(include) {
intervals.add(interval);
}
}
return intervals;
}
示例7: between
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
public static Range<LocalDate> between(LocalDate from, LocalDate to) {
return Range.between(from, to, new Comparator<LocalDate>() {
@Override
public int compare(LocalDate o1, LocalDate o2) {
return o1.compareTo(o2);
}
});
}
示例8: getRange
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
public static Range<Integer> getRange(Tree tree) {
Tree firstLeaf = firstLeaf(tree);
Tree lastLeaf = lastLeaf(tree);
return Range.between(
((OffsetLabel) firstLeaf.label()).beginPosition(),
((OffsetLabel) lastLeaf.label()).endPosition());
}
示例9: parseRangeInt
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
public static Range<Integer> parseRangeInt(String str) {
Matcher m = RANGE_PATTERN.matcher(str);
Validate.isTrue(m.find(), "Illegal range str: %s", str);
return Range.between(
Integer.parseInt(m.group(1)),
Integer.parseInt(m.group(3)));
}
示例10: parseRangeDouble
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
public static Range<Double> parseRangeDouble(String str) {
Matcher m = RANGE_PATTERN.matcher(str);
Validate.isTrue(m.find(), "Illegal range str: %s", str);
return Range.between(
Double.parseDouble(m.group(1)),
Double.parseDouble(m.group(3)));
}
示例11: testIsBefore
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
@Test
public void testIsBefore() {
Range<Integer> range1 = Range.between(299, 311);
Range<Integer> range2 = Range.between(299, 305);
assertTrue(RangeUtils.isBefore(range1, range2));
assertTrue(RangeUtils.isBefore(range2, range1));
}
示例12: testIsBefore2
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
@Test
public void testIsBefore2() {
Range<Integer> range1 = Range.between(146, 151);
Range<Integer> range2 = Range.between(148, 151);
assertTrue(RangeUtils.isBefore(range1, range2));
}
示例13: getDateRange
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
private Range<Date> getDateRange() {
Date endDate = DateUtils.truncate(new Date(), Calendar.MINUTE);
Date startDate = DateUtils.addMinutes(endDate,
-YiDuConstants.yiduConf.getInt(YiDuConfig.SEND_SUBSCRIBE_INTEVAL, 15));
return Range.between(startDate, endDate);
}
示例14: getGoldRange
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
@Override
public Range<Integer> getGoldRange()
{
return Range.between(10, 30);
}
示例15: getGoldRange
import org.apache.commons.lang3.Range; //导入方法依赖的package包/类
@Override
public Range<Integer> getGoldRange()
{
return Range.between(20, 40);
}