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

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

Introduction

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

Prototype

public static <T> T checkNotNull(T reference) 

Source Link

Document

Ensures that an object reference passed as a parameter to the calling method is not null.

Usage

From source file:org.mifos.sdk.client.domain.commands.UpdateSavingsAccountCommand.java

/**
 * Sets the savings account ID of the client.
 * @param id the savings account ID/* ww  w. java 2s .c  o m*/
 * @return a new instance of {@link Builder}
 */
public static Builder savingsAccountId(final Long id) {
    Preconditions.checkNotNull(id);

    return new Builder(id);
}

From source file:com.google.gplus.serializer.util.GPlusEventClassifier.java

public static Class detectClass(String json) {
    Preconditions.checkNotNull(json);
    Preconditions.checkArgument(StringUtils.isNotEmpty(json));

    ObjectNode objectNode;/*from w  ww  . j  a  v a  2  s.c om*/
    try {
        objectNode = (ObjectNode) mapper.readTree(json);
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }

    if (objectNode.findValue("kind") != null && objectNode.get("kind").toString().equals(ACTIVITY_IDENTIFIER)) {
        return Activity.class;
    } else if (objectNode.findValue("kind") != null
            && objectNode.get("kind").toString().equals(PERSON_IDENTIFIER)) {
        return Person.class;
    } else {
        return ObjectNode.class;
    }
}

From source file:com.turn.splicer.tsdbutils.JSON.java

public static <T> T parseToObject(final String json, final Class<T> pojo) {
    Preconditions.checkNotNull(json);
    Preconditions.checkArgument(!json.isEmpty(), "Incoming data was null or empty");
    Preconditions.checkNotNull(pojo);//from   w  ww . ja v  a 2s  . c  o m

    try {
        return jsonMapper.readValue(json, pojo);
    } catch (IOException e) {
        throw new JSONException(e);
    }
}

From source file:cz.cuni.mff.ms.brodecva.botnicek.ide.check.code.model.builder.DefaultCodeBuilderFactory.java

/**
 * Vytvo tovrnu./*from   www . j av  a  2 s  .c o  m*/
 * 
 * @param checker
 *            validtor
 * @return tovrna
 */
public static DefaultCodeBuilderFactory create(final CodeChecker checker) {
    Preconditions.checkNotNull(checker);

    return new DefaultCodeBuilderFactory(checker);
}

From source file:eu.thebluemountain.customers.dctm.brownbag.badcontentslister.ExtensionResolver.java

/**
 * The method that creates a new extension resolver
 * @param stores carries the identifiers of stores using extensions
 * @param extensions is the function which, given a format name, returns
 *                   the matching file's extension.
 * @return the matching extension resolver
 *//*from ww w.  j  a v  a 2s  .c  o  m*/
public static ExtensionResolver create(ImmutableSet<String> stores, Function<String, String> extensions) {
    return new ExtensionResolver(Preconditions.checkNotNull(stores), Preconditions.checkNotNull(extensions));
}

From source file:com.jb.repair.nfc.simulator.FakeTagsActivity.java

public static NdefRecord newTextRecord(String text, Locale locale, boolean encodeInUtf8) {
    Preconditions.checkNotNull(text);
    Preconditions.checkNotNull(locale);/*from  w ww  . jav a 2  s.c o  m*/
    final byte[] langBytes = locale.getLanguage().getBytes(Charsets.US_ASCII);
    final Charset utfEncoding = encodeInUtf8 ? Charsets.UTF_8 : Charset.forName("UTF-16");
    final byte[] textBytes = text.getBytes(utfEncoding);
    final int utfBit = encodeInUtf8 ? 0 : (1 << 7);
    final char status = (char) (utfBit + langBytes.length);
    final byte[] data = Bytes.concat(new byte[] { (byte) status }, langBytes, textBytes);
    return new NdefRecord(NdefRecord.TNF_WELL_KNOWN, NdefRecord.RTD_TEXT, new byte[0], data);
}

From source file:com.enonic.cms.core.portal.livetrace.PortalRequestTraceRow.java

public PortalRequestTraceRow(final PortalRequestTrace portalRequestTrace) {
    Preconditions.checkNotNull(portalRequestTrace);

    this.portalRequestTrace = portalRequestTrace;
    this.completedNumber = portalRequestTrace.getCompletedNumber();
    this.type = portalRequestTrace.getType();
    this.url = resolveURL(portalRequestTrace);
    this.started = portalRequestTrace.getDuration().getStartTime().toString();
    this.duration = portalRequestTrace.getDuration();
}

From source file:org.xacml4j.v30.types.BooleanExp.java

public static BooleanExp valueOf(Boolean v) {
    Preconditions.checkNotNull(v);
    return v ? BooleanExp.TRUE : BooleanExp.FALSE;
}

From source file:org.onos.yangtools.restconf.client.api.dto.RestRpcService.java

public RestRpcService(String namespace) {
    Preconditions.checkNotNull(namespace);
    this.namespace = namespace;
}

From source file:csv4j.RichField.java

/**
 * Factory method for creating a field enriched with its setter method
 * /*from  w  w  w. j a v  a2 s .co m*/
 * @param type
 *            domain type
 * @param field
 *            type's field
 * @return enriched field with setter method
 */
static RichField of(final Class<?> type, final Field field) {
    Preconditions.checkNotNull(type);
    Preconditions.checkNotNull(field);
    String fieldName = field.getName();
    Class<?> fieldType = field.getType();
    String setterName = setterName(fieldName);
    Method method = Sane.declaredMethod(type, setterName, fieldType);
    return new RichField(field, method);
}