本文整理匯總了Java中com.google.common.collect.RangeSet.contains方法的典型用法代碼示例。如果您正苦於以下問題:Java RangeSet.contains方法的具體用法?Java RangeSet.contains怎麽用?Java RangeSet.contains使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.RangeSet
的用法示例。
在下文中一共展示了RangeSet.contains方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildNonUpdatingTasksFilter
import com.google.common.collect.RangeSet; //導入方法依賴的package包/類
private static Predicate<IAssignedTask> buildNonUpdatingTasksFilter(
final Map<IJobKey, IJobUpdateInstructions> roleJobUpdates) {
return task -> {
Optional<IJobUpdateInstructions> update = Optional.fromNullable(
roleJobUpdates.get(task.getTask().getJob()));
if (update.isPresent()) {
IJobUpdateInstructions instructions = update.get();
RangeSet<Integer> initialInstances = getInstanceIds(instructions.getInitialState());
RangeSet<Integer> desiredInstances = getInstanceIds(instructions.isSetDesiredState()
? ImmutableSet.of(instructions.getDesiredState())
: ImmutableSet.of());
int instanceId = task.getInstanceId();
return !initialInstances.contains(instanceId) && !desiredInstances.contains(instanceId);
}
return true;
};
}
示例2: filterWithRangeSet
import com.google.common.collect.RangeSet; //導入方法依賴的package包/類
/**
* Filter out the values for which the tokens are not included within the specified range.
*
* @param tokens the tokens range
* @param values the restricted values
* @return the values for which the tokens are not included within the specified range.
*/
private List<ByteBuffer> filterWithRangeSet(RangeSet<Token> tokens, List<ByteBuffer> values)
{
List<ByteBuffer> remaining = new ArrayList<>();
for (ByteBuffer value : values)
{
Token token = partitioner.getToken(value);
if (!tokens.contains(token))
continue;
remaining.add(value);
}
return remaining;
}
示例3: queryNotification
import com.google.common.collect.RangeSet; //導入方法依賴的package包/類
public List<NotificationBaseType> queryNotification(String connectionId, Optional<Long> startNotificationId, Optional<Long> endNotificationId, NsiV2RequestDetails requestDetails) {
NsiRequesterConnection connection = connectionRepo.findByConnectionId(connectionId);
if (connection == null) {
return Collections.emptyList();
}
RangeSet<Long> notificationRange = TreeRangeSet.create();
if (startNotificationId.isPresent() && endNotificationId.isPresent()) {
notificationRange.add(Range.closed(startNotificationId.get(), endNotificationId.get()));
} else if (startNotificationId.isPresent() && !endNotificationId.isPresent()) {
notificationRange.add(Range.atLeast(startNotificationId.get()));
} else if (endNotificationId.isPresent() && !startNotificationId.isPresent()) {
notificationRange.add(Range.atMost(endNotificationId.get()));
} else {
notificationRange.add(Range.<Long>all());
}
List<NotificationBaseType> selectedNotifications = new ArrayList<>();
for (NotificationBaseType notification : connection.getNotifications()) {
if (notificationRange.contains(notification.getNotificationId())) {
selectedNotifications.add(notification);
}
}
return Lists.newArrayList(selectedNotifications);
}
示例4: inBannedSet
import com.google.common.collect.RangeSet; //導入方法依賴的package包/類
private static boolean inBannedSet(CharOffsetSpan span, RangeSet<Integer> bannedRegions) {
return bannedRegions.contains(span.startInclusive())
|| bannedRegions.contains(span.endInclusive());
}
示例5: reorderModifiers
import com.google.common.collect.RangeSet; //導入方法依賴的package包/類
/**
* Reorders all modifiers in the given text and within the given character ranges to be in JLS
* order.
*/
static JavaInput reorderModifiers(JavaInput javaInput, Collection<Range<Integer>> characterRanges)
throws FormatterException {
if (javaInput.getTokens().isEmpty()) {
// There weren't any tokens, possible because of a lexing error.
// Errors about invalid input will be reported later after parsing.
return javaInput;
}
RangeSet<Integer> tokenRanges = javaInput.characterRangesToTokenRanges(characterRanges);
Iterator<? extends Token> it = javaInput.getTokens().iterator();
TreeRangeMap<Integer, String> replacements = TreeRangeMap.create();
while (it.hasNext()) {
Token token = it.next();
if (!tokenRanges.contains(token.getTok().getIndex())) {
continue;
}
Modifier mod = asModifier(token);
if (mod == null) {
continue;
}
List<Token> modifierTokens = new ArrayList<>();
List<Modifier> mods = new ArrayList<>();
int begin = token.getTok().getPosition();
mods.add(mod);
modifierTokens.add(token);
int end = -1;
while (it.hasNext()) {
token = it.next();
mod = asModifier(token);
if (mod == null) {
break;
}
mods.add(mod);
modifierTokens.add(token);
end = token.getTok().getPosition() + token.getTok().length();
}
if (!Ordering.natural().isOrdered(mods)) {
Collections.sort(mods);
StringBuilder replacement = new StringBuilder();
for (int i = 0; i < mods.size(); i++) {
if (i > 0) {
addTrivia(replacement, modifierTokens.get(i).getToksBefore());
}
replacement.append(mods.get(i).toString());
if (i < (modifierTokens.size() - 1)) {
addTrivia(replacement, modifierTokens.get(i).getToksAfter());
}
}
replacements.put(Range.closedOpen(begin, end), replacement.toString());
}
}
return applyReplacements(javaInput, replacements);
}
示例6: reorderModifiers
import com.google.common.collect.RangeSet; //導入方法依賴的package包/類
/**
* Reorders all modifiers in the given text and within the given character ranges to be in JLS
* order.
*/
static JavaInput reorderModifiers(JavaInput javaInput, Collection<Range<Integer>> characterRanges)
throws FormatterException {
if (javaInput.getTokens().isEmpty()) {
// There weren't any tokens, possible because of a lexing error.
// Errors about invalid input will be reported later after parsing.
return javaInput;
}
RangeSet<Integer> tokenRanges = javaInput.characterRangesToTokenRanges(characterRanges);
Iterator<? extends Token> it = javaInput.getTokens().iterator();
TreeRangeMap<Integer, String> replacements = TreeRangeMap.create();
while (it.hasNext()) {
Token token = it.next();
if (!tokenRanges.contains(token.getTok().getIndex())) {
continue;
}
Modifier mod = asModifier(token);
if (mod == null) {
continue;
}
List<Token> modifierTokens = new ArrayList<>();
List<Modifier> mods = new ArrayList<>();
int begin = token.getTok().getPosition();
mods.add(mod);
modifierTokens.add(token);
int end = -1;
while (it.hasNext()) {
token = it.next();
mod = asModifier(token);
if (mod == null) {
break;
}
mods.add(mod);
modifierTokens.add(token);
end = token.getTok().getPosition() + token.getTok().length();
}
if (!Ordering.natural().isOrdered(mods)) {
Collections.sort(mods);
StringBuilder replacement = new StringBuilder();
for (int i = 0; i < mods.size(); i++) {
if (i > 0) {
addTrivia(replacement, modifierTokens.get(i).getToksBefore());
}
replacement.append(mods.get(i).toString());
if (i < (modifierTokens.size() - 1)) {
addTrivia(replacement, modifierTokens.get(i).getToksAfter());
}
}
replacements.put(Range.closedOpen(begin, end), replacement.toString());
}
}
return applyReplacements(javaInput, replacements);
}
示例7: canAddToAutoBlackList
import com.google.common.collect.RangeSet; //導入方法依賴的package包/類
/**
* Goes through the white and black lists to check if an ip address from the access logs is a
* valid candidate to add to the auto blacklist.
*
* @param doNotAutoBlockIpRangeSet The Ip Range Set of ips we do not want to black list
* @param ipFromAccessLog The IP Address we are considering to automatically black list
* @return A boolean of whether or not this processor should black list the ip.
*/
protected boolean canAddToAutoBlackList(RangeSet<Integer> doNotAutoBlockIpRangeSet, String ipFromAccessLog) {
SubnetUtils subnetUtils = new SubnetUtils(ipFromAccessLog, NETMASK_FOR_SINGLE_IP);
Integer ipAsInteger = subnetUtils.getInfo().asInteger(ipFromAccessLog);
return ! doNotAutoBlockIpRangeSet.contains(ipAsInteger);
}