Example usage for com.google.common.base CharMatcher isNot

List of usage examples for com.google.common.base CharMatcher isNot

Introduction

In this page you can find the example usage for com.google.common.base CharMatcher isNot.

Prototype

public static CharMatcher isNot(final char match) 

Source Link

Document

Returns a char matcher that matches any character except the one specified.

Usage

From source file:com.platzhaltr.readr.functions.TrimLeftFunction.java

@Override
public String apply(final String input) {
    return CharMatcher.WHITESPACE.and(CharMatcher.isNot(' ')).trimTrailingFrom(input);
}

From source file:brooklyn.rest.security.provider.LdapSecurityProvider.java

public LdapSecurityProvider(ManagementContext mgmt) {
    StringConfigMap properties = mgmt.getConfig();
    ldapUrl = properties.getConfig(BrooklynWebConfig.LDAP_URL);
    Strings.checkNonEmpty(ldapUrl,/* w  ww . j  ava2  s .c om*/
            "LDAP security provider configuration missing required property " + BrooklynWebConfig.LDAP_URL);
    ldapRealm = CharMatcher.isNot('"').retainFrom(properties.getConfig(BrooklynWebConfig.LDAP_REALM));
    Strings.checkNonEmpty(ldapRealm,
            "LDAP security provider configuration missing required property " + BrooklynWebConfig.LDAP_REALM);
}

From source file:org.apache.brooklyn.rest.security.provider.LdapSecurityProvider.java

public LdapSecurityProvider(ManagementContext mgmt) {
    StringConfigMap properties = mgmt.getConfig();
    ldapUrl = properties.getConfig(BrooklynWebConfig.LDAP_URL);
    Strings.checkNonEmpty(ldapUrl,//from w w w . j a va 2s.co m
            "LDAP security provider configuration missing required property " + BrooklynWebConfig.LDAP_URL);
    ldapRealm = CharMatcher.isNot('"').retainFrom(properties.getConfig(BrooklynWebConfig.LDAP_REALM));
    Strings.checkNonEmpty(ldapRealm,
            "LDAP security provider configuration missing required property " + BrooklynWebConfig.LDAP_REALM);

    if (Strings.isBlank(properties.getConfig(BrooklynWebConfig.LDAP_OU))) {
        LOG.info("Setting LDAP ou attribute to: Users");
        organizationUnit = "Users";
    } else {
        organizationUnit = CharMatcher.isNot('"').retainFrom(properties.getConfig(BrooklynWebConfig.LDAP_OU));
    }
    Strings.checkNonEmpty(ldapRealm,
            "LDAP security provider configuration missing required property " + BrooklynWebConfig.LDAP_OU);
}

From source file:com.a9ski.brooklyn.LdapSecurityProvider.java

public LdapSecurityProvider(ManagementContext mgmt) {
    StringConfigMap properties = mgmt.getConfig();
    ldapUrl = properties.getConfig(BrooklynWebConfig.LDAP_URL);
    Strings.checkNonEmpty(ldapUrl,//from   w w w.  ja  v  a2 s . co  m
            "LDAP security provider configuration missing required property " + BrooklynWebConfig.LDAP_URL);
    ldapRealm = CharMatcher.isNot('"').retainFrom(properties.getConfig(BrooklynWebConfig.LDAP_REALM));
    Strings.checkNonEmpty(ldapRealm,
            "LDAP security provider configuration missing required property " + BrooklynWebConfig.LDAP_REALM);

    if (Strings.isBlank(properties.getConfig(BrooklynWebConfig.LDAP_OU))) {
        LOG.info("Setting LDAP ou attribute to: Users");
        organizationUnit = "Users";
    } else {
        organizationUnit = CharMatcher.isNot('"').retainFrom(properties.getConfig(BrooklynWebConfig.LDAP_OU));
    }

    final String userPatternProp = properties.getConfig(LDAP_USER_PATTERN);
    if (Strings.isBlank(userPatternProp)) {
        userPattern = DEFAULT_USER_PATTERN;
    } else {
        userPattern = userPatternProp;
    }
    LOG.info("Setting LDAP user pattern to: " + userPatternProp);

    Strings.checkNonEmpty(ldapRealm,
            "LDAP security provider configuration missing required property " + BrooklynWebConfig.LDAP_OU);
}

From source file:com.google.errorprone.bugpatterns.MixedArrayDimensions.java

private Description checkArrayDimensions(Tree tree, Tree type, VisitorState state) {
    if (!(type instanceof ArrayTypeTree)) {
        return NO_MATCH;
    }/*from www .  j a  v a 2s  . c om*/
    CharSequence source = state.getSourceCode();
    for (; type instanceof ArrayTypeTree; type = ((ArrayTypeTree) type).getType()) {
        Tree elemType = ((ArrayTypeTree) type).getType();
        int start = state.getEndPosition(elemType);
        int end = state.getEndPosition(type);
        if (start >= end) {
            continue;
        }
        String dim = source.subSequence(start, end).toString();
        if (dim.isEmpty()) {
            continue;
        }
        ImmutableList<ErrorProneToken> tokens = ErrorProneTokens.getTokens(dim.trim(), state.context);
        if (tokens.size() > 2 && tokens.get(0).kind() == TokenKind.IDENTIFIER) {
            int nonWhitespace = CharMatcher.isNot(' ').indexIn(dim);
            int idx = dim.indexOf("[]", nonWhitespace);
            if (idx > nonWhitespace) {
                String replacement = dim.substring(idx, dim.length()) + dim.substring(0, idx);
                return describeMatch(tree, SuggestedFix.replace(start, end, replacement));
            }
        }
    }
    return NO_MATCH;
}

From source file:com.google.googlejavaformat.java.RemoveUnusedImports.java

/** Construct replacements to fix unused imports. */
private static RangeMap<Integer, String> buildReplacements(String contents, JCCompilationUnit unit,
        Set<String> usedNames, Multimap<String, Range<Integer>> usedInJavadoc) {
    RangeMap<Integer, String> replacements = TreeRangeMap.create();
    for (JCImport importTree : unit.getImports()) {
        String simpleName = getSimpleName(importTree);
        if (!isUnused(unit, usedNames, usedInJavadoc, importTree, simpleName)) {
            continue;
        }/*  w w  w.j av  a2s.  com*/
        // delete the import
        int endPosition = importTree.getEndPosition(unit.endPositions);
        endPosition = Math.max(CharMatcher.isNot(' ').indexIn(contents, endPosition), endPosition);
        String sep = Newlines.guessLineSeparator(contents);
        if (endPosition + sep.length() < contents.length()
                && contents.subSequence(endPosition, endPosition + sep.length()).toString().equals(sep)) {
            endPosition += sep.length();
        }
        replacements.put(Range.closedOpen(importTree.getStartPosition(), endPosition), "");
        // fully qualify any javadoc references with the same simple name as a deleted
        // non-static import
        if (!importTree.isStatic()) {
            for (Range<Integer> docRange : usedInJavadoc.get(simpleName)) {
                if (docRange == null) {
                    continue;
                }
                String replaceWith = importTree.getQualifiedIdentifier().toString();
                replacements.put(docRange, replaceWith);
            }
        }
    }
    return replacements;
}

From source file:com.google.googlejavaformat.java.javadoc.JavadocLexer.java

private static void deindentPreCodeBlock(ImmutableList.Builder<Token> output, PeekingIterator<Token> tokens) {
    Deque<Token> saved = new ArrayDeque<>();
    output.add(new Token(LITERAL, tokens.next().getValue().trim()));
    while (tokens.hasNext() && tokens.peek().getType() != PRE_CLOSE_TAG) {
        Token token = tokens.next();/*from  w ww.  j a va  2s  .  com*/
        saved.addLast(token);
    }
    while (!saved.isEmpty() && saved.peekFirst().getType() == FORCED_NEWLINE) {
        saved.removeFirst();
    }
    while (!saved.isEmpty() && saved.peekLast().getType() == FORCED_NEWLINE) {
        saved.removeLast();
    }
    if (saved.isEmpty()) {
        return;
    }

    // move the trailing `}` to its own line
    Token last = saved.peekLast();
    boolean trailingBrace = false;
    if (last.getType() == LITERAL && last.getValue().endsWith("}")) {
        saved.removeLast();
        if (last.length() > 1) {
            saved.addLast(new Token(LITERAL, last.getValue().substring(0, last.getValue().length() - 1)));
            saved.addLast(new Token(FORCED_NEWLINE, null));
        }
        trailingBrace = true;
    }

    int trim = -1;
    for (Token token : saved) {
        if (token.getType() == LITERAL) {
            int idx = CharMatcher.isNot(' ').indexIn(token.getValue());
            if (idx != -1 && (trim == -1 || idx < trim)) {
                trim = idx;
            }
        }
    }

    output.add(new Token(FORCED_NEWLINE, "\n"));
    for (Token token : saved) {
        if (token.getType() == LITERAL) {
            output.add(new Token(LITERAL,
                    trim > 0 && token.length() > trim ? token.getValue().substring(trim) : token.getValue()));
        } else {
            output.add(token);
        }
    }

    if (trailingBrace) {
        output.add(new Token(LITERAL, "}"));
    } else {
        output.add(new Token(FORCED_NEWLINE, "\n"));
    }
}