org.checkerframework.checker.nullness.qual.Nullable Java Examples

The following examples show how to use org.checkerframework.checker.nullness.qual.Nullable. 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: ThrottledAsyncChecker.java    From hadoop-ozone with Apache License 2.0 6 votes vote down vote up
/**
 * Register a callback to cache the result of a check.
 * @param target
 * @param lf
 */
private void addResultCachingCallback(
    Checkable<K, V> target, ListenableFuture<V> lf) {
  Futures.addCallback(lf, new FutureCallback<V>() {
    @Override
    public void onSuccess(@Nullable V result) {
      synchronized (ThrottledAsyncChecker.this) {
        checksInProgress.remove(target);
        completedChecks.put(target, new LastCheckResult<>(
            result, timer.monotonicNow()));
      }
    }

    @Override
    public void onFailure(@Nonnull Throwable t) {
      synchronized (ThrottledAsyncChecker.this) {
        checksInProgress.remove(target);
        completedChecks.put(target, new LastCheckResult<>(
            t, timer.monotonicNow()));
      }
    }
  }, MoreExecutors.directExecutor());
}
 
Example #2
Source File: AttributeNameTableCell.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void updateAttr(@Nullable Attribute attr) {
    if (tooltip != null) {
        Tooltip.uninstall(this, tooltip);
        getStyleClass().remove(DEPRECATED_CSS_CLASS);
        tooltip = null;
    }

    if (attr == null) {
        return;
    }

    String replacement = attr.replacementIfDeprecated();
    if (replacement != null) {
        String txt = "This attribute is deprecated";
        if (!replacement.isEmpty()) {
            txt += ", please use " + replacement + " instead";
        }
        Tooltip t = new Tooltip(txt);
        tooltip = t;
        getStyleClass().add(DEPRECATED_CSS_CLASS);
        Tooltip.install(this, t);
    }
}
 
Example #3
Source File: XPathAutocompleteProvider.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Nullable
private Tuple2<Integer, String> getInsertionPointAndQuery(int searchPoint) {
    String input = myCodeArea.getText();

    int insertionPoint = getInsertionPoint(searchPoint, input);

    if (searchPoint > input.length()) {
        searchPoint = input.length();
    }
    if (insertionPoint > searchPoint) {
        new StringIndexOutOfBoundsException("Cannot extract query from subtext \"" + input.substring(0, insertionPoint) + "\"").printStackTrace();
        return null;
    }

    // don't trim, if there is any whitespace we abort
    input = input.substring(insertionPoint, searchPoint);

    return StringUtils.isAlpha(input) ? Tuples.t(insertionPoint, input.trim()) : null;
}
 
Example #4
Source File: GDCore.java    From GriefDefender with MIT License 6 votes vote down vote up
@Override
public @Nullable Claim getClaim(UUID uuid) {
    for (World world : Bukkit.getServer().getWorlds()) {
        final ClaimManager claimManager = this.getClaimManager(world.getUID());
        if (claimManager == null) {
            continue;
        }
        if (claimManager.getWildernessClaim().getUniqueId().equals(uuid)) {
            return claimManager.getWildernessClaim();
        }
        for (Claim claim : claimManager.getWorldClaims()) {
            if (claim.getUniqueId().equals(uuid)) {
                return claim;
            }
        }
    }

    return null;
}
 
Example #5
Source File: PropertyMapModel.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void setKnownProperties(@Nullable ObservableList<PropertyDescriptorSpec> props) {
    ObservableList<PropertyDescriptorSpec> safe = defaultToEmpty(props);
    getNonDefault().forEach((k, v) -> {
        if (safe.stream().noneMatch(it -> it.getName().equals(k))) {
            orphanProperties.put(k, v);
        }
    });
    knownPropsImpl.setValue(props); // we need to keep a null value in there for it to be replaced later on
    mapping.forEach((k, v) -> {
        String orphan = orphanProperties.get(k.getName());
        if (orphan != null) {
            orphanProperties.remove(k.getName());
            v.setValue(orphan);
        }
    });
}
 
Example #6
Source File: EconomyDataConfig.java    From GriefDefender with MIT License 6 votes vote down vote up
@Override
public @Nullable Vector3i getRentSignPosition() {
    if (this.rentSignPos == null) {
        return null;
    }

    if (this.rentSignVec == null) {
        try {
            this.rentSignVec = BlockUtil.getInstance().posFromString(this.rentSignPos);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    return this.rentSignVec;
}
 
Example #7
Source File: EconomyDataConfig.java    From GriefDefender with MIT License 6 votes vote down vote up
@Override
public @Nullable Vector3i getSaleSignPosition() {
    if (this.saleSignPos == null) {
        return null;
    }

    if (this.saleSignVec == null) {
        try {
            this.saleSignVec = BlockUtil.getInstance().posFromString(this.saleSignPos);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    return this.saleSignVec;
}
 
Example #8
Source File: CauseContextHelper.java    From GriefDefender with MIT License 6 votes vote down vote up
@Nullable
public static GDPermissionUser getEventUser(Location location, PlayerTracker.Type trackerType) {
    final GDPermissionUser user = GDCauseStackManager.getInstance().getCurrentCause().first(GDPermissionUser.class).orElse(null);
    if (user != null) {
        return user;
    }
    if (location == null) {
        return null;
    }

    final GDClaimManager claimWorldManager = GriefDefenderPlugin.getInstance().dataStore.getClaimWorldManager(location.getWorld().getUID());
    final GDChunk gdChunk = claimWorldManager.getChunk(location.getChunk());
    if (trackerType != null) {
        if (trackerType == PlayerTracker.Type.OWNER) {
            return gdChunk.getBlockOwner(location);
        }
        return gdChunk.getBlockNotifier(location);
    }

    return gdChunk.getBlockUser(location);
}
 
Example #9
Source File: PlayerUtil.java    From GriefDefender with MIT License 6 votes vote down vote up
@Nullable
public String getUserName(UUID uuid) {
    if (uuid.equals(GriefDefenderPlugin.PUBLIC_UUID)) {
        return "public";
    }
    if (uuid.equals(GriefDefenderPlugin.ADMIN_USER_UUID) || uuid.equals(GriefDefenderPlugin.WORLD_USER_UUID)) {
        return "administrator";
    }

    final GDPermissionUser user = PermissionHolderCache.getInstance().getOrCreateUser(uuid);
    if (user == null) {
        return "unknown";
    }
    if (user.getName() != null) {
        return user.getName();
    }
    // check offline player
    final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
    if (offlinePlayer == null) {
        return "unknown";
    }
    return offlinePlayer.getName();
}
 
Example #10
Source File: SimplePopups.java    From pmd-designer with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Nullable
private static Node getIconLiteral(AlertType type) {
    @Nullable String iconLit;
    switch (type) {
    case ERROR:
        iconLit = "fas-times";
        break;
    case CONFIRMATION:
        iconLit = "fas-check";
        break;
    case INFORMATION:
        iconLit = "fas-info";
        break;
    case WARNING:
        iconLit = "fas-exclamation";
        break;
    default:
        iconLit = null;
        break;
    }

    return iconLit == null ? null : new FontIcon(iconLit);
}
 
Example #11
Source File: GDCore.java    From GriefDefender with MIT License 6 votes vote down vote up
@Override
public @Nullable Claim getClaim(UUID uuid) {
    for (World world : Sponge.getServer().getWorlds()) {
        final ClaimManager claimManager = this.getClaimManager(world.getUniqueId());
        if (claimManager == null) {
            continue;
        }
        if (claimManager.getWildernessClaim().getUniqueId().equals(uuid)) {
            return claimManager.getWildernessClaim();
        }
        for (Claim claim : claimManager.getWorldClaims()) {
            if (claim.getUniqueId().equals(uuid)) {
                return claim;
            }
        }
    }

    return null;
}
 
Example #12
Source File: EconomyDataConfig.java    From GriefDefender with MIT License 6 votes vote down vote up
@Override
public @Nullable Vector3i getRentSignPosition() {
    if (this.rentSignPos == null) {
        return null;
    }

    if (this.rentSignVec == null) {
        try {
            this.rentSignVec = BlockUtil.getInstance().posFromString(this.rentSignPos);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    return this.rentSignVec;
}
 
Example #13
Source File: EconomyDataConfig.java    From GriefDefender with MIT License 6 votes vote down vote up
@Override
public @Nullable Vector3i getSaleSignPosition() {
    if (this.saleSignPos == null) {
        return null;
    }

    if (this.saleSignVec == null) {
        try {
            this.saleSignVec = BlockUtil.getInstance().posFromString(this.saleSignPos);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    return this.saleSignVec;
}
 
Example #14
Source File: ProxyMonitorService.java    From influx-proxy with Apache License 2.0 5 votes vote down vote up
public void onPing(ProxyInstance proxyInstance){
    @Nullable ProxyInstance existProxyInstance = proxyInstanceCache.getIfPresent(proxyInstance.toString());
    if(existProxyInstance==null){
       proxyInstanceCache.put(proxyInstance.toString(),proxyInstance);
    }
    existProxyInstance=proxyInstanceCache.getIfPresent(proxyInstance.toString());
    if(existProxyInstance!=null){
        existProxyInstance.setLastTimestamp(new Date());
    }
}
 
Example #15
Source File: LiveTestCase.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public LiveTestCase(@Nullable ObservableRuleBuilder owner) {
    freeze();
    rule.setValue(owner);

    rule.values().subscribe(
        r -> liveProperties.setKnownProperties(r == null ? null : r.getRuleProperties())
    );
}
 
Example #16
Source File: HddsVolumeChecker.java    From hadoop-ozone with Apache License 2.0 5 votes vote down vote up
/**
 * @param healthyVolumes set of healthy volumes. If the disk check is
 *                       successful, add the volume here.
 * @param failedVolumes  set of failed volumes. If the disk check fails,
 *                       add the volume here.
 * @param volumeCounter  volumeCounter used to trigger callback invocation.
 * @param callback       invoked when the volumeCounter reaches 0.
 */
ResultHandler(HddsVolume volume,
    Set<HddsVolume> healthyVolumes,
    Set<HddsVolume> failedVolumes,
    AtomicLong volumeCounter,
    @Nullable Callback callback) {
  this.volume = volume;
  this.healthyVolumes = healthyVolumes;
  this.failedVolumes = failedVolumes;
  this.volumeCounter = volumeCounter;
  this.callback = callback;
}
 
Example #17
Source File: SimplePopups.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Show a transient popup with a message, to let the user know an action
 * was performed.
 *
 * @param owner Node next to which the popup will be shown
 * @return
 */
public static EventStream<?> showActionFeedback(@NonNull Node owner,
                                                @Nullable Node graphic,
                                                @NonNull String message,
                                                double offsetX,
                                                boolean stick,
                                                String... cssClasses) {

    Popup popup = new Popup();
    Label label = new Label(message, graphic);
    StackPane pane = new StackPane();

    DesignerUtil.addCustomStyleSheets(pane, "designer");
    pane.getStyleClass().addAll("action-feedback");
    pane.getStyleClass().addAll(cssClasses);

    pane.getChildren().addAll(label);
    popup.getContent().addAll(pane);

    Animation fadeTransition = stick ? fadeInAnimation(pane) : bounceFadeAnimation(pane);
    EventSource<?> closeTick = new EventSource<>();
    if (stick) {
        pane.setOnMouseClicked(evt -> {
            popup.hide();
            closeTick.push(null);
        });
    } else {
        fadeTransition.setOnFinished(e -> {
            popup.hide();
            closeTick.push(null);
        });
    }

    popup.setOnShowing(e -> fadeTransition.play());

    Bounds screenBounds = owner.localToScreen(owner.getBoundsInLocal());
    popup.show(owner, screenBounds.getMaxX() + offsetX, screenBounds.getMinY());
    return closeTick;
}
 
Example #18
Source File: SyntaxHighlightingCodeArea.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Update the syntax highlighting to the specified value.
 * If null, syntax highlighting is stripped off.
 */
private void setCurrentSyntaxHighlight(final @Nullable StyleSpans<Collection<String>> newSyntax) {
    StyleSpans<Collection<String>> oldSyntaxHighlight = currentSyntaxHighlight.getValue();
    this.currentSyntaxHighlight.setValue(newSyntax);

    setStyleSpans(0, styleSyntaxHighlightChange(oldSyntaxHighlight, newSyntax));
}
 
Example #19
Source File: HighlightLayerCodeArea.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Attempts to preserve the other layers when syntax highlighting changes. The result
 * misplaces some style classes, which is undesirable, but covered up by the subsequent
 * parsing update.
 */
@Override
@NonNull
protected final StyleSpans<Collection<String>> styleSyntaxHighlightChange(final @Nullable StyleSpans<Collection<String>> oldSyntax,
                                                                          final @Nullable StyleSpans<Collection<String>> newSyntax) {

    StyleSpans<Collection<String>> currentSpans = getStyleSpans(new IndexRange(0, getLength()));
    StyleSpans<Collection<String>> base = Optional.ofNullable(oldSyntax).map(s -> subtract(currentSpans, s)).orElse(currentSpans);

    return Optional.ofNullable(newSyntax)
                   .map(s -> base.overlay(s, SyntaxHighlightingCodeArea::additiveOverlay))
                   .orElse(base)
                   .subView(0, getLength());
}
 
Example #20
Source File: Functions.java    From beihu-boot with Apache License 2.0 5 votes vote down vote up
@Override
public boolean equals(@Nullable Object o) {
    if (o instanceof ForMapWithAbsentFunction) {
        ForMapWithAbsentFunction<?, ?> that = (ForMapWithAbsentFunction<?, ?>) o;
        return map.equals(that.map) && Objects.equals(absentFunction, that.absentFunction);
    }
    return false;
}
 
Example #21
Source File: ReactfxUtil.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Add a hook on the owner window. It's not possible to do this statically,
 * since at construction time the window might not be set.
 */
public static <T> Subscription subscribeDisposable(ObservableValue<@Nullable ? extends T> node,
                                                   Function<@NonNull ? super T, Subscription> subscriber) {
    return ReactfxExtensions.dynamic(
        LiveList.wrapVal(node),
        (w, i) -> subscriber.apply(w)
    );
}
 
Example #22
Source File: AuxLanguageRegistry.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Nullable
public static synchronized LanguageVersion getLanguageVersionFromExtension(String filename) {
    if (extensionsToLanguage == null) {
        extensionsToLanguage = getExtensionsToLanguageMap();
    }

    if (filename.indexOf('.') > 0) {
        String[] tokens = filename.split("\\.");
        return extensionsToLanguage.get(tokens[tokens.length - 1]);
    }
    return null;
}
 
Example #23
Source File: GDClaimManager.java    From GriefDefender with MIT License 5 votes vote down vote up
@Nullable
public Set<Claim> getPlayerClaims(UUID playerUniqueId) {
    final GDPlayerData playerData = this.getPlayerDataMap().get(playerUniqueId);
    if (playerData == null) {
        return ImmutableSet.of();
    }
    return ImmutableSet.copyOf(this.getPlayerDataMap().get(playerUniqueId).getInternalClaims());
}
 
Example #24
Source File: GDClaim.java    From GriefDefender with MIT License 5 votes vote down vote up
@Nullable
public TownDataConfig getTownData() {
    if (!(this.claimData instanceof TownDataConfig)) {
        return null;
    }

    return (TownDataConfig) this.claimData;
}
 
Example #25
Source File: GDCallbackHolder.java    From GriefDefender with MIT License 5 votes vote down vote up
@Nullable
public Consumer<CommandSender> getCallbackForUUID(UUID id) {
    final Consumer<CommandSender> consumer = reverseMap.get(id);
    final UUID playerUniqueId = confirmConsumerMap.inverse().get(id);
    if (playerUniqueId != null) {
        reverseMap.remove(id);
        confirmConsumerMap.remove(playerUniqueId);
    }
    return consumer;
}
 
Example #26
Source File: EconomyDataConfig.java    From GriefDefender with MIT License 5 votes vote down vote up
@Override
public @Nullable Instant getSaleEndDate() {
    if (this.saleEndDate == null) {
        return null;
    }
    try {
        return Instant.parse(this.saleEndDate);
    } catch (DateTimeParseException e) {
        return null;
    }
}
 
Example #27
Source File: GDClaimManager.java    From GriefDefender with MIT License 5 votes vote down vote up
@Nullable
public Set<Claim> getPlayerClaims(UUID playerUniqueId) {
    final GDPlayerData playerData = this.getPlayerDataMap().get(playerUniqueId);
    if (playerData == null) {
        return ImmutableSet.of();
    }
    return ImmutableSet.copyOf(this.getPlayerDataMap().get(playerUniqueId).getInternalClaims());
}
 
Example #28
Source File: GDClaim.java    From GriefDefender with MIT License 5 votes vote down vote up
@Nullable
public TownDataConfig getTownData() {
    if (!(this.claimData instanceof TownDataConfig)) {
        return null;
    }

    return (TownDataConfig) this.claimData;
}
 
Example #29
Source File: GDCallbackHolder.java    From GriefDefender with MIT License 5 votes vote down vote up
@Nullable
public Consumer<CommandSource> getCallbackForUUID(UUID id) {
    final Consumer<CommandSource> consumer = reverseMap.get(id);
    final UUID playerUniqueId = confirmConsumerMap.inverse().get(id);
    if (playerUniqueId != null) {
        reverseMap.remove(id);
        confirmConsumerMap.remove(playerUniqueId);
    }
    return consumer;
}
 
Example #30
Source File: EconomyDataConfig.java    From GriefDefender with MIT License 5 votes vote down vote up
@Override
public @Nullable Instant getSaleEndDate() {
    if (this.saleEndDate == null) {
        return null;
    }
    try {
        return Instant.parse(this.saleEndDate);
    } catch (DateTimeParseException e) {
        return null;
    }
}