Example usage for com.google.common.base Preconditions checkArgument

List of usage examples for com.google.common.base Preconditions checkArgument

Introduction

In this page you can find the example usage for com.google.common.base Preconditions checkArgument.

Prototype

public static void checkArgument(boolean expression) 

Source Link

Document

Ensures the truth of an expression involving one or more parameters to the calling method.

Usage

From source file:org.sonar.flex.checks.utils.Function.java

public static String getName(AstNode functionDef) {
    Preconditions.checkArgument(functionDef.is(FlexGrammar.FUNCTION_DEF));
    return functionDef.getFirstChild(FlexGrammar.FUNCTION_NAME).getFirstChild(FlexGrammar.IDENTIFIER)
            .getTokenValue();//w  w  w.j a v  a2 s .co m
}

From source file:org.sonar.flex.checks.utils.Variable.java

public static String getName(AstNode varDeclStatement) {
    Preconditions.checkArgument(varDeclStatement.is(FlexGrammar.VARIABLE_DECLARATION_STATEMENT));
    return varDeclStatement.getFirstChild(FlexGrammar.VARIABLE_DEF)
            .getFirstChild(FlexGrammar.VARIABLE_BINDING_LIST).getFirstChild(FlexGrammar.VARIABLE_BINDING)
            .getFirstChild(FlexGrammar.TYPED_IDENTIFIER).getFirstChild(FlexGrammar.IDENTIFIER).getTokenValue();
}

From source file:com.sebrichard.mfgen.MetaFieldUtil.java

public static String fieldNameFromMetaField(@NotNull PsiField field) {
    Preconditions.checkArgument(isMetaField(field));

    return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, field.getName().replaceFirst(PREFIX, ""));
}

From source file:com.cloudera.nav.sdk.model.custom.Namespace.java

public static Namespace newNamespace(String name) {
    Preconditions.checkArgument(StringUtils.isNotEmpty(name));
    Namespace ns = new Namespace();
    ns.setName(name);//from  ww w .ja v  a2  s .c o  m
    return ns;
}

From source file:org.sonar.lua.checks.utils.Function.java

public static String getName(AstNode functionDef) {
    Preconditions.checkArgument(functionDef.is(LuaGrammar.LOCALFUNCSTAT));
    return functionDef.getFirstChild(LuaGrammar.NAME).getTokenValue();

}

From source file:com.android.contacts.interactions.ContactInteractionUtil.java

/**
 * @return a string like (?,?,?...) with {@param count} question marks.
 *//*from  ww w.  j  a v  a 2  s  .c om*/
@NeededForTesting
public static String questionMarks(int count) {
    Preconditions.checkArgument(count > 0);
    StringBuilder sb = new StringBuilder("(?");
    for (int i = 1; i < count; i++) {
        sb.append(",?");
    }
    return sb.append(")").toString();
}

From source file:net.ltgt.guice.neo4j.Neo4jIndexProviders.java

public static Provider<Index<Node>> indexForNodes(final String name) {
    Preconditions.checkArgument(!Strings.isNullOrEmpty(name));
    return new Provider<Index<Node>>() {

        @Inject/*from   w w w .  j  a  va  2  s  .  c  o  m*/
        IndexManager indexManager;

        @Override
        public Index<Node> get() {
            return indexManager.forNodes(name);
        }
    };
}

From source file:org.apache.fluo.accumulo.util.ReadLockUtil.java

public static long encodeTs(long ts, boolean isDelete) {
    Preconditions.checkArgument((ts & ColumnConstants.PREFIX_MASK) == 0);
    return ts << 1 | (isDelete ? 1 : 0);
}

From source file:org.zanata.rest.service.MockResourceUtil.java

static void validateExtensions(Set<String> extensions) {
    Preconditions.checkArgument(extensions == null || extensions.isEmpty() || extensions.contains("gettext")
            || extensions.contains("comment"));
}

From source file:com.zaradai.kunzite.optimizer.model.SchemaUtils.java

public static String intArrayToHexUsingShort(int[] data) {
    char[] hexChars = new char[data.length * NUM_NIBBLE_IN_SHORT];

    for (int j = 0; j < data.length; j++) {
        Preconditions.checkArgument(data[j] <= MAX_UNSIGNED_SHORT_VALUE);

        hexChars[j * NUM_NIBBLE_IN_SHORT] = HEX_ARRAY[(data[j] & 0xF000) >>> 12];
        hexChars[j * NUM_NIBBLE_IN_SHORT + 1] = HEX_ARRAY[(data[j] & 0x0F00) >>> 8];
        hexChars[j * NUM_NIBBLE_IN_SHORT + 2] = HEX_ARRAY[(data[j] & 0x00F0) >>> 4];
        hexChars[j * NUM_NIBBLE_IN_SHORT + 3] = HEX_ARRAY[data[j] & 0x0F];
    }/*from  www  .j  a  v a2  s.co m*/
    return new String(hexChars);
}