Example usage for org.apache.commons.lang3 Validate notNull

List of usage examples for org.apache.commons.lang3 Validate notNull

Introduction

In this page you can find the example usage for org.apache.commons.lang3 Validate notNull.

Prototype

public static <T> T notNull(final T object) 

Source Link

Document

Validate that the specified argument is not null ; otherwise throwing an exception.

Usage

From source file:io.cloudslang.lang.entities.utils.ResultUtils.java

public static boolean isDefaultResult(Result result) {
    Validate.notNull(result);
    Serializable rawValue = result.getValue() == null ? null : result.getValue().get();
    return rawValue == null || Boolean.TRUE.equals(rawValue);
}

From source file:com.github.aynu.mosir.core.standard.lang.SpecHelper.java

/**
 * ?(NOT)??//www. j a  v a  2s  . c  o  m
 * @param <T> ?
 * @param spec 
 * @return ?(NOT)
 */
public static <T> Spec<T> not(final Spec<T> spec) {
    Validate.notNull(spec);
    return new AbstractSpec<T>(spec) {
        /** {@inheritDoc} */
        @Override
        public boolean isSatisfiedBy(final T object) {
            return !getSpec1().isSatisfiedBy(object);
        }
    };
}

From source file:ca.travelagency.persistence.query.Where.java

static Where make(String whereAsSql, List<Object> parameters) {
    Validate.notNull(whereAsSql);
    Validate.notNull(parameters);/*  w  w w . j a va2s .  c om*/
    Where result = new Where();
    result.whereAsSql = whereAsSql;
    result.parameters = parameters;
    return result;
}

From source file:ca.travelagency.utils.UploadUtils.java

public static File getUploadFolder(String companyFolder) {
    Validate.notNull(companyFolder);
    File folder = new File(MAIN_FOLDER + companyFolder, UPLOAD_FOLDER);
    folder.mkdirs();//from   w w  w.ja  va 2  s  .  c  om
    return folder;
}

From source file:com.kamesuta.mc.signpic.asm.lib.VisitorHelper.java

public static byte[] apply(final @Nonnull byte[] bytes, final @Nonnull String name,
        final @Nonnull TransformProvider context) {
    Validate.notNull(bytes);
    final ClassReader cr = new ClassReader(bytes);
    final ClassWriter cw = new ClassWriter(cr, context.flags);
    final ClassVisitor mod = context.createVisitor(name, cw);

    try {//from  ww w.  ja v  a  2 s.  c o m
        cr.accept(mod, 0);
        return cw.toByteArray();
    } catch (final StopTransforming e) {
        return bytes;
    }
}

From source file:com.offbynull.coroutines.instrumenter.InternalUtils.java

@SuppressWarnings("unchecked")
static <T extends ContinuationPoint> T validateAndGetContinuationPoint(MethodAttributes attrs, int idx,
        Class<T> expectedType) {
    Validate.notNull(attrs);
    Validate.notNull(expectedType);/*from  w ww  .  j  a v a2 s  .  c  o m*/
    Validate.isTrue(idx >= 0);

    List<ContinuationPoint> continuationPoints = attrs.getContinuationPoints();
    Validate.isTrue(idx < continuationPoints.size());

    ContinuationPoint continuationPoint = continuationPoints.get(idx);
    Validate.isTrue(expectedType.isAssignableFrom(continuationPoint.getClass()));

    return (T) continuationPoint;
}

From source file:controllers.base.LoggedAction.java

public static String getLogEntry(Context ctx, String message) {
    if (ctx == null) {
        ctx = Context.current();/*from   w  w w .j a  va 2s  . c  om*/
        Validate.notNull(ctx);
    }

    return String.format(
            "%s - { request-method: %s, request-uri: %s, username: %s, remote-address: %s, session: %s }",
            message, ctx.request().method(), ctx.request().uri(),
            StringUtils.defaultIfEmpty(SessionedAction.getUsername(ctx), "anonymous"),
            ctx.request().remoteAddress(),
            StringUtils.defaultIfEmpty(SessionedAction.getSessionKey(ctx), "none"));
}

From source file:ca.travelagency.utils.StringUtils.java

public static String format(String... sources) {
    Validate.notNull(sources);
    StringBuilder stringBuilder = new StringBuilder();
    for (String source : sources) {
        if (StringUtils.isNotBlank(source)) {
            if (stringBuilder.length() > 0) {
                stringBuilder.append(SEPERATOR);
            }// w w w. ja  v  a 2 s. c o m
            stringBuilder.append(source);
        }
    }
    return stringBuilder.toString();
}

From source file:at.pcgamingfreaks.StringUtils.java

public static boolean arrayContains(@NotNull String[] strings, @Nullable String searchFor) {
    Validate.notNull(strings);
    for (String s : strings) {
        //noinspection ConstantConditions
        if ((s != null && s.equals(searchFor)) || (s == null && searchFor == null)) {
            return true;
        }//from  w ww  . j  a v  a2s.c  om
    }
    return false;
}

From source file:de.digiway.rapidbreeze.server.infrastructure.rest.download.DownloadResourceFactory.java

/**
 * Creates a RESTful {@linkplain DownloadResource} resource from the given
 * {@linkplain Download}./* ww  w .j  av a  2 s. com*/
 *
 * @param download
 * @return
 */
public static DownloadResource create(Download download) {
    Validate.notNull(download);
    DownloadResource.Builder builder = new DownloadResource.Builder();
    UrlStatus urlStatus = download.getUrlStatus();

    return builder.identifier(download.getIdentifier()).url(download.getUrl())
            .downloadStatus(download.getDownloadStatus()).targetFile(download.getFile().toString())
            .filename(download.getFilename()).provider(download.getProviderName())
            .currentFilesize(download.getCurrentSize()).filesize(urlStatus.getFileSize())
            .progress(download.getProgress()).bytesPerSecond(download.getBytesPerSecond())
            .eta(download.getEta()).build();
}