org.antlr.v4.runtime.misc.NotNull Java Examples

The following examples show how to use org.antlr.v4.runtime.misc.NotNull. 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: PropertyConfigUtils.java    From synopsys-detect with Apache License 2.0 5 votes vote down vote up
/**
 * Will get the first property in a list that was provided by the user.
 * If no property was provided, the default will NOT be used.
 */
public static <T> Optional<T> getFirstProvidedValueOrEmpty(@NotNull PropertyConfiguration propertyConfiguration, @NotNull ValuedProperty<T>... properties) {
    for (ValuedProperty<T> property : properties) {
        if (propertyConfiguration.wasPropertyProvided(property)) {
            return Optional.of(propertyConfiguration.getValueOrDefault(property));
        }
    }

    return Optional.empty();
}
 
Example #2
Source File: PropertyConfiguration.java    From synopsys-detect with Apache License 2.0 5 votes vote down vote up
@NotNull
public <T> T getValueOrDefault(@NotNull final ValuedProperty<T> property) {
    assertPropertyNotNull(property);
    try {
        return getValue(property);
    } catch (final InvalidPropertyException e) {
        return property.getDefaultValue();
    }
}
 
Example #3
Source File: PropertyResolutionInfo.java    From synopsys-detect with Apache License 2.0 5 votes vote down vote up
public PropertyResolutionInfo(@NotNull final String source, @NotNull final String origin, @NotNull final String raw) {
    Assert.notNull(source, "Source cannot be null.");
    Assert.notNull(origin, "Origin cannot be null.");
    Assert.notNull(raw, "Raw cannot be null.");
    this.source = source;
    this.origin = origin;
    this.raw = raw;
}
 
Example #4
Source File: PropertyConfiguration.java    From synopsys-detect with Apache License 2.0 5 votes vote down vote up
@NotNull
private <T> PropertyValue<T> coerceValue(@NotNull final TypedProperty<T> property, @NotNull final PropertyResolutionInfo propertyResolutionInfo) {
    Assert.notNull(property, "Cannot resolve a null property.");
    Assert.notNull(propertyResolutionInfo, "Cannot coerce a null property resolution.");
    try {
        final T value = property.getValueParser().parse(propertyResolutionInfo.getRaw());
        return new ValuedPropertyValue<>(value, propertyResolutionInfo);
    } catch (final ValueParseException e) {
        return new ExceptionPropertyValue<>(e, propertyResolutionInfo);
    }
}
 
Example #5
Source File: PropertyConfiguration.java    From synopsys-detect with Apache License 2.0 5 votes vote down vote up
@NotNull
private <T> PropertyValue<T> valueFromCache(@NotNull final TypedProperty<T> property) {
    if (!valueCache.containsKey(property.getKey())) {
        valueCache.put(property.getKey(), valueFromResolution(property));
    }

    @SuppressWarnings("unchecked") final PropertyValue<T> value = (PropertyValue<T>) valueCache.get(property.getKey());
    Assert.notNull(value, "Could not source a value, something has gone wrong with properties!");
    return value;
}
 
Example #6
Source File: PropertyConfiguration.java    From synopsys-detect with Apache License 2.0 5 votes vote down vote up
@NotNull
public <T> Optional<T> getValueOrEmpty(@NotNull final NullableProperty<T> property) {
    assertPropertyNotNull(property);
    try {
        return getValue(property);
    } catch (final InvalidPropertyException e) {
        return Optional.empty();
    }
}
 
Example #7
Source File: PropertyConfiguration.java    From synopsys-detect with Apache License 2.0 5 votes vote down vote up
private PropertyResolution resolveFromPropertySources(@NotNull final String key) {
    Assert.notNull(key, "Cannot resolve a null key.");
    for (final PropertySource propertySource : orderedPropertySources) {
        if (propertySource.hasKey(key)) {
            final String rawValue = propertySource.getValue(key);
            if (rawValue != null) {
                final String name = propertySource.getName();
                final String origin = propertySource.getOrigin(key);
                final PropertyResolutionInfo propertyResolutionInfo = new PropertyResolutionInfo(name, origin, rawValue);
                return new SourcePropertyResolution(propertyResolutionInfo);
            }
        }
    }
    return new NoPropertyResolution();
}
 
Example #8
Source File: PropertyConfiguration.java    From synopsys-detect with Apache License 2.0 5 votes vote down vote up
@NotNull
public Set<String> getKeys() {
    return orderedPropertySources.stream()
               .map(PropertySource::getKeys)
               .flatMap(Set::stream)
               .collect(Collectors.toSet());
}
 
Example #9
Source File: ConnectionDetails.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
@NotNull
public List<Pattern> getIgnoredProxyHostPatterns() {
    return ignoredProxyHostPatterns;
}
 
Example #10
Source File: ConnectionDetails.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
@NotNull
public Long getTimeout() {
    return timeout;
}
 
Example #11
Source File: PropertyConfiguration.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
public <T> Optional<ValueParseException> getPropertyException(@NotNull final TypedProperty<T> property) {
    assertPropertyNotNull(property);
    return valueFromCache(property).getException();
}
 
Example #12
Source File: Category.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
@NotNull
public String getName() {
    return name;
}
 
Example #13
Source File: SoftEnumValue.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
@NotNull
public static <E extends Enum<E>> SoftEnumValue<E> ofEnumValue(@NotNull final E enumValue) {
    return new SoftEnumValue<>(null, enumValue);
}
 
Example #14
Source File: ExecutableRunner.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
@NotNull
ExecutableOutput execute(final File workingDirectory, final File exeFile, final String... args) throws ExecutableRunnerException;
 
Example #15
Source File: PropertySource.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
@NotNull
Boolean hasKey(String key);
 
Example #16
Source File: PropertyConfiguration.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
public <T> boolean wasPropertyProvided(@NotNull final TypedProperty<T> property) {
    assertPropertyNotNull(property);
    return wasKeyProvided(property.getKey());
}
 
Example #17
Source File: ConnectionDetails.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
@NotNull
public ProxyInfo getProxyInformation() {
    return proxyInformation;
}
 
Example #18
Source File: Group.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
@NotNull
String getName();
 
Example #19
Source File: PropertyResolutionInfo.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
@NotNull
public String getRaw() {
    return raw;
}
 
Example #20
Source File: BlackDuckConnectionDetails.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
@NotNull
public Map<String, String> getBlackduckProperties() {
    return blackduckProperties;
}
 
Example #21
Source File: ProductMajorVersion.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
@NotNull
public String getDisplayValue() {
    return String.format("%s.0.0", getIntValue());
}
 
Example #22
Source File: Category.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
protected Category(@NotNull final String name) {
    this.name = name;
}
 
Example #23
Source File: EqlGrammarListener.java    From openemm with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Exit a parse tree produced by the {@code StartsWithRelationalExpression}
 * labeled alternative in {@link EqlGrammarParser#relational_expression}.
 * @param ctx the parse tree
 */
void exitStartsWithRelationalExpression(@NotNull EqlGrammarParser.StartsWithRelationalExpressionContext ctx);
 
Example #24
Source File: EqlGrammarBaseListener.java    From openemm with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * <p>The default implementation does nothing.</p>
 */
@Override public void enterSubExpression(@NotNull EqlGrammarParser.SubExpressionContext ctx) { }
 
Example #25
Source File: EqlGrammarBaseListener.java    From openemm with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * <p>The default implementation does nothing.</p>
 */
@Override public void exitAtomFactor(@NotNull EqlGrammarParser.AtomFactorContext ctx) { }
 
Example #26
Source File: EqlGrammarListener.java    From openemm with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Enter a parse tree produced by the {@code ParenthesisBooleanNotExpression}
 * labeled alternative in {@link EqlGrammarParser#boolean_not_expression}.
 * @param ctx the parse tree
 */
void enterParenthesisBooleanNotExpression(@NotNull EqlGrammarParser.ParenthesisBooleanNotExpressionContext ctx);
 
Example #27
Source File: EqlGrammarBaseListener.java    From openemm with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * <p>The default implementation does nothing.</p>
 */
@Override public void exitSubExpression(@NotNull EqlGrammarParser.SubExpressionContext ctx) { }
 
Example #28
Source File: EqlGrammarBaseListener.java    From openemm with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * <p>The default implementation does nothing.</p>
 */
@Override public void enterStringDoubleQuote(@NotNull EqlGrammarParser.StringDoubleQuoteContext ctx) { }
 
Example #29
Source File: EqlGrammarBaseListener.java    From openemm with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * <p>The default implementation does nothing.</p>
 */
@Override public void exitNumeric_constant(@NotNull EqlGrammarParser.Numeric_constantContext ctx) { }
 
Example #30
Source File: EqlGrammarBaseListener.java    From openemm with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * <p>The default implementation does nothing.</p>
 */
@Override public void exitEqRelationalRelationalExpression(@NotNull EqlGrammarParser.EqRelationalRelationalExpressionContext ctx) { }